From c4ce24647bb45b54db9ad37a21c36e65658fea68 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Tue, 3 Dec 2019 11:58:10 +0000 Subject: [PATCH] fix(compiler-cli): ensure that `ngI18nClosureMode` is guarded in generated code (#34211) If the `ngI18nClosureMode` global check actually makes it through to the runtime, then checks for its existence should be guarded to prevent `Reference undefined` errors in strict mode. (Normally, it is stripped out by dead code elimination during build optimization.) This comment ensures that generated template code guards this global check. PR Close #34211 --- .../compliance/r3_view_compiler_i18n_spec.ts | 204 +++++++++--------- .../compiler/src/render3/view/template.ts | 23 +- 2 files changed, 120 insertions(+), 107 deletions(-) diff --git a/packages/compiler-cli/test/compliance/r3_view_compiler_i18n_spec.ts b/packages/compiler-cli/test/compliance/r3_view_compiler_i18n_spec.ts index 9133c2c705..8b27d767b2 100644 --- a/packages/compiler-cli/test/compliance/r3_view_compiler_i18n_spec.ts +++ b/packages/compiler-cli/test/compliance/r3_view_compiler_i18n_spec.ts @@ -195,7 +195,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc descA * @meaning meaningA @@ -207,7 +207,7 @@ describe('i18n support in the template compiler', () => { $I18N_0$ = $localize \`:meaningA|descA@@idA:Content A\`; } var $I18N_3$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc descB * @meaning meaningB @@ -220,7 +220,7 @@ describe('i18n support in the template compiler', () => { } const $_c5$ = ["title", $I18N_3$]; var $I18N_7$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @meaning meaningC */ @@ -232,7 +232,7 @@ describe('i18n support in the template compiler', () => { } const $_c9$ = ["title", $I18N_7$]; var $I18N_11$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc descD * @meaning meaningD @@ -245,7 +245,7 @@ describe('i18n support in the template compiler', () => { } const $_c13$ = ["title", $I18N_11$]; var $I18N_15$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc meaningE */ @@ -257,7 +257,7 @@ describe('i18n support in the template compiler', () => { } const $_c17$ = ["title", $I18N_15$]; var $I18N_19$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_idF$$APP_SPEC_TS_20$ = goog.getMsg("Title F"); $I18N_19$ = $MSG_EXTERNAL_idF$$APP_SPEC_TS_20$; } @@ -266,7 +266,7 @@ describe('i18n support in the template compiler', () => { } const $_c21$ = ["title", $I18N_19$]; var $I18N_23$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc [BACKUP_$` + String.raw `{MESSAGE}_ID:idH]` + @@ -280,7 +280,7 @@ describe('i18n support in the template compiler', () => { } const $_c25$ = ["title", $I18N_23$]; var $I18N_20$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc Some text \' [BACKUP_MESSAGE_ID: xxx] */ @@ -381,7 +381,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc d * @meaning m @@ -422,7 +422,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_5526535577705876535$$APP_SPEC_TS_1$ = goog.getMsg("static text"); $I18N_1$ = $MSG_EXTERNAL_5526535577705876535$$APP_SPEC_TS_1$; } @@ -430,7 +430,7 @@ describe('i18n support in the template compiler', () => { $I18N_1$ = $localize \`static text\`; } var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc d * @meaning m @@ -445,7 +445,7 @@ describe('i18n support in the template compiler', () => { String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`; } var $I18N_3$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc d1 * @meaning m1 @@ -465,7 +465,7 @@ describe('i18n support in the template compiler', () => { "aria-label", $I18N_3$ ]; var $I18N_6$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc d2 * @meaning m2 @@ -482,7 +482,7 @@ describe('i18n support in the template compiler', () => { String.raw `{"\uFFFD2\uFFFD"}:INTERPOLATION_2:\`; } var $I18N_7$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_6639222533406278123$$APP_SPEC_TS_7$ = goog.getMsg("{$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }); @@ -529,7 +529,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc d * @meaning m @@ -571,7 +571,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc d * @meaning m @@ -625,7 +625,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_3462388422673575127$$APP_SPEC_TS_2$ = goog.getMsg("{$interpolation} title", { "interpolation": "\uFFFD0\uFFFD" }); @@ -673,7 +673,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_5526535577705876535$$APP_SPEC_TS_1$ = goog.getMsg("static text"); $I18N_1$ = $MSG_EXTERNAL_5526535577705876535$$APP_SPEC_TS_1$; } @@ -681,7 +681,7 @@ describe('i18n support in the template compiler', () => { $I18N_1$ = $localize \`static text\`; } var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc d * @meaning m @@ -696,7 +696,7 @@ describe('i18n support in the template compiler', () => { String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`; } var $I18N_3$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc d1 * @meaning m1 @@ -716,7 +716,7 @@ describe('i18n support in the template compiler', () => { "aria-label", $I18N_3$ ]; var $I18N_6$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc d2 * @meaning m2 @@ -733,7 +733,7 @@ describe('i18n support in the template compiler', () => { String.raw `{"\uFFFD2\uFFFD"}:INTERPOLATION_2:\`; } var $I18N_7$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_6639222533406278123$$APP_SPEC_TS_7$ = goog.getMsg("{$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }); @@ -785,7 +785,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc d * @meaning m @@ -839,7 +839,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc d * @meaning m @@ -852,7 +852,7 @@ describe('i18n support in the template compiler', () => { } const $_c1$ = ["title", $I18N_0$]; var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_4969674997806975147$$APP_SPEC_TS_2$ = goog.getMsg("Some content"); $I18N_2$ = $MSG_EXTERNAL_4969674997806975147$$APP_SPEC_TS_2$; } @@ -882,7 +882,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_ID_WITH_INVALID_CHARS$$APP_SPEC_TS_1$ = goog.getMsg("Element title"); $I18N_0$ = $MSG_EXTERNAL_ID_WITH_INVALID_CHARS$$APP_SPEC_TS_1$; } @@ -891,7 +891,7 @@ describe('i18n support in the template compiler', () => { } const $_c1$ = ["title", $I18N_0$]; var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_ID_WITH_INVALID_CHARS_2$$APP_SPEC_TS_4$ = goog.getMsg(" Some content "); $I18N_2$ = $MSG_EXTERNAL_ID_WITH_INVALID_CHARS_2$$APP_SPEC_TS_4$; } @@ -943,7 +943,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_APP_SPEC_TS_1$ = goog.getMsg("Some text"); $I18N_0$ = $MSG_APP_SPEC_TS_1$; } @@ -961,7 +961,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_4924931801512133405$$APP_SPEC_TS_0$ = goog.getMsg("Some text 'with single quotes', \"with double quotes\", ` + '`with backticks`' + String.raw ` and without quotes."); $I18N_0$ = $MSG_EXTERNAL_4924931801512133405$$APP_SPEC_TS_0$; @@ -978,7 +978,7 @@ describe('i18n support in the template compiler', () => { const input = '
`{{ count }}`
'; const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_APP_SPEC_TS_1$ = goog.getMsg("` + '`{$interpolation}`' + String.raw `", { "interpolation": "\uFFFD0\uFFFD" }); $I18N_0$ = $MSG_APP_SPEC_TS_1$; @@ -1001,7 +1001,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS_0$ = goog.getMsg("My i18n block #1"); $I18N_0$ = $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS_0$; } @@ -1009,7 +1009,7 @@ describe('i18n support in the template compiler', () => { $I18N_0$ = $localize \`My i18n block #1\`; } var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_2413150872298537152$$APP_SPEC_TS_1$ = goog.getMsg("My i18n block #2"); $I18N_1$ = $MSG_EXTERNAL_2413150872298537152$$APP_SPEC_TS_1$; } @@ -1017,7 +1017,7 @@ describe('i18n support in the template compiler', () => { $I18N_1$ = $localize \`My i18n block #2\`; } var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_5023003143537152794$$APP_SPEC_TS_2$ = goog.getMsg("My i18n block #3"); $I18N_2$ = $MSG_EXTERNAL_5023003143537152794$$APP_SPEC_TS_2$; } @@ -1059,7 +1059,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7597881511811528589$$APP_SPEC_TS_0$ = goog.getMsg(" Named interpolation: {$phA} Named interpolation with spaces: {$phB} ", { "phA": "\uFFFD0\uFFFD", "phB": "\uFFFD1\uFFFD" @@ -1097,7 +1097,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_6749967533321674787$$APP_SPEC_TS_0$ = goog.getMsg("{$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }); @@ -1134,7 +1134,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_APP_SPEC_TS_1$$APP_SPEC_TS_1$ = goog.getMsg(" {$interpolation} {$interpolation_1} {$interpolation_2} ", { "interpolation": "\uFFFD0\uFFFD", "interpolation_1": "\uFFFD1\uFFFD", @@ -1176,7 +1176,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_572579892698764378$$APP_SPEC_TS_0$ = goog.getMsg("My i18n block #{$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }); @@ -1187,7 +1187,7 @@ describe('i18n support in the template compiler', () => { String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`; } var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_609623417156596326$$APP_SPEC_TS_1$ = goog.getMsg("My i18n block #{$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }); @@ -1198,7 +1198,7 @@ describe('i18n support in the template compiler', () => { String.raw `{"\uFFFD0\uFFFD"}:INTERPOLATION:\`; } var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_3998119318957372120$$APP_SPEC_TS_2$ = goog.getMsg("My i18n block #{$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }); @@ -1258,7 +1258,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7905233330103651696$$APP_SPEC_TS_0$ = goog.getMsg(" My i18n block #{$interpolation} {$startTagSpan}Plain text in nested element{$closeTagSpan}", { "interpolation": "\uFFFD0\uFFFD", "startTagSpan": "\uFFFD#2\uFFFD", @@ -1273,7 +1273,7 @@ describe('i18n support in the template compiler', () => { String.raw `{"\uFFFD/#2\uFFFD"}:CLOSE_TAG_SPAN:\`; } var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_5788821996131681377$$APP_SPEC_TS_1$ = goog.getMsg(" My i18n block #{$interpolation} {$startTagDiv}{$startTagDiv}{$startTagSpan} More bindings in more nested element: {$interpolation_1} {$closeTagSpan}{$closeTagDiv}{$closeTagDiv}", { "interpolation": "\uFFFD0\uFFFD", "startTagDiv": "[\uFFFD#6\uFFFD|\uFFFD#7\uFFFD]", @@ -1347,7 +1347,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_4782264005467235841$$APP_SPEC_TS_3$ = goog.getMsg("Span title {$interpolation} and {$interpolation_1}", { "interpolation": "\uFFFD0\uFFFD", "interpolation_1": "\uFFFD1\uFFFD" @@ -1361,7 +1361,7 @@ describe('i18n support in the template compiler', () => { } const $_c4$ = ["title", $I18N_2$]; var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_4446430594603971069$$APP_SPEC_TS_5$ = goog.getMsg(" My i18n block #1 with value: {$interpolation} {$startTagSpan} Plain text in nested element (block #1) {$closeTagSpan}", { "interpolation": "\uFFFD0\uFFFD", "startTagSpan": "\uFFFD#2\uFFFD", @@ -1376,7 +1376,7 @@ describe('i18n support in the template compiler', () => { String.raw `{"\uFFFD/#2\uFFFD"}:CLOSE_TAG_SPAN:\`; } var $I18N_7$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_2719594642740200058$$APP_SPEC_TS_8$ = goog.getMsg("Span title {$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }); @@ -1388,7 +1388,7 @@ describe('i18n support in the template compiler', () => { } const $_c9$ = ["title", $I18N_7$]; var $I18N_6$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_2778714953278357902$$APP_SPEC_TS_10$ = goog.getMsg(" My i18n block #2 with value {$interpolation} {$startTagSpan} Plain text in nested element (block #2) {$closeTagSpan}", { "interpolation": "\uFFFD0\uFFFD", "startTagSpan": "\uFFFD#7\uFFFD", @@ -1457,7 +1457,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7679414751795588050$$APP_SPEC_TS__1$ = goog.getMsg(" Some other content {$interpolation} {$startTagDiv} More nested levels with bindings {$interpolation_1} {$closeTagDiv}", { "interpolation": "\uFFFD0\uFFFD", "startTagDiv": "\uFFFD#3\uFFFD", @@ -1526,7 +1526,7 @@ describe('i18n support in the template compiler', () => { } } var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_2367729185105559721$$APP_SPEC_TS__2$ = goog.getMsg("App logo #{$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }); @@ -1631,7 +1631,7 @@ describe('i18n support in the template compiler', () => { } } var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_1221890473527419724$$APP_SPEC_TS_0$ = goog.getMsg(" Some content {$startTagDiv_2} Some other content {$interpolation} {$startTagDiv} More nested levels with bindings {$interpolation_1} {$startTagDiv_1} Content inside sub-template {$interpolation_2} {$startTagDiv} Bottom level element {$interpolation_3} {$closeTagDiv}{$closeTagDiv}{$closeTagDiv}{$closeTagDiv}{$startTagDiv_3} Some other content {$interpolation_4} {$startTagDiv} More nested levels with bindings {$interpolation_5} {$closeTagDiv}{$closeTagDiv}", { "startTagDiv_2": "\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD", "closeTagDiv": "[\uFFFD/#2:2\uFFFD|\uFFFD/#1:2\uFFFD\uFFFD/*4:2\uFFFD|\uFFFD/#2:1\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD|\uFFFD/#2:3\uFFFD|\uFFFD/#1:3\uFFFD\uFFFD/*3:3\uFFFD]", @@ -1722,7 +1722,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_119975189388320493$$APP_SPEC_TS__1$ = goog.getMsg("Some other content {$startTagSpan}{$interpolation}{$closeTagSpan}", { "startTagSpan": "\uFFFD#2\uFFFD", "interpolation": "\uFFFD0\uFFFD", @@ -1775,7 +1775,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_APP_SPEC_TS_2$ = goog.getMsg("Hello"); $I18N_1$ = $MSG_APP_SPEC_TS_2$; } @@ -1806,7 +1806,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS_0$ = goog.getMsg("My i18n block #1"); $I18N_0$ = $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS_0$; } @@ -1833,7 +1833,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}"); $I18N_0$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$; } @@ -1870,7 +1870,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_2413150872298537152$$APP_SPEC_TS_0$ = goog.getMsg("My i18n block #2"); $I18N_0$ = $MSG_EXTERNAL_2413150872298537152$$APP_SPEC_TS_0$; } @@ -1878,7 +1878,7 @@ describe('i18n support in the template compiler', () => { $I18N_0$ = $localize \`My i18n block #2\`; } var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS__1$ = goog.getMsg("My i18n block #1"); $I18N_1$ = $MSG_EXTERNAL_4890179241114413722$$APP_SPEC_TS__1$; } @@ -1912,7 +1912,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_5295701706185791735$$APP_SPEC_TS_1$ = goog.getMsg("Text #1"); $I18N_1$ = $MSG_EXTERNAL_5295701706185791735$$APP_SPEC_TS_1$; } @@ -1920,7 +1920,7 @@ describe('i18n support in the template compiler', () => { $I18N_1$ = $localize \`Text #1\`; } var $I18N_3$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_4722270221386399294$$APP_SPEC_TS_3$ = goog.getMsg("Text #2"); $I18N_3$ = $MSG_EXTERNAL_4722270221386399294$$APP_SPEC_TS_3$; } @@ -1955,7 +1955,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_355394464191978948$$APP_SPEC_TS_0$ = goog.getMsg("Some content: {$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }); @@ -1992,7 +1992,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_355394464191978948$$APP_SPEC_TS__0$ = goog.getMsg("Some content: {$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }); @@ -2035,7 +2035,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_702706566400598764$$APP_SPEC_TS_0$ = goog.getMsg("{$startTagNgTemplate}Template content: {$interpolation}{$closeTagNgTemplate}{$startTagNgContainer}Container content: {$interpolation_1}{$closeTagNgContainer}", { "startTagNgTemplate": "\uFFFD*2:1\uFFFD", "closeTagNgTemplate": "\uFFFD/*2:1\uFFFD", @@ -2097,7 +2097,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}"); $I18N_0$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$; } @@ -2108,7 +2108,7 @@ describe('i18n support in the template compiler', () => { "VAR_SELECT": "\uFFFD0\uFFFD" }); var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS__1$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_1$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS__1$; } @@ -2187,7 +2187,7 @@ describe('i18n support in the template compiler', () => { } } var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_2051477021417799640$$APP_SPEC_TS_0$ = goog.getMsg("{$startTagNgTemplate} Template A: {$interpolation} {$startTagNgTemplate} Template B: {$interpolation_1} {$startTagNgTemplate} Template C: {$interpolation_2} {$closeTagNgTemplate}{$closeTagNgTemplate}{$closeTagNgTemplate}", { "startTagNgTemplate": "[\uFFFD*2:1\uFFFD|\uFFFD*2:2\uFFFD|\uFFFD*1:3\uFFFD]", "closeTagNgTemplate": "[\uFFFD/*1:3\uFFFD|\uFFFD/*2:2\uFFFD|\uFFFD/*2:1\uFFFD]", @@ -2251,7 +2251,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_0$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$; } @@ -2262,7 +2262,7 @@ describe('i18n support in the template compiler', () => { "VAR_SELECT": "\uFFFD0\uFFFD" }); var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS__1$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}"); $I18N_1$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS__1$; } @@ -2314,7 +2314,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_4891196282781544695$$APP_SPEC_TS_0$ = goog.getMsg("{$tagImg} is my logo #1 ", { "tagImg": "\uFFFD#2\uFFFD\uFFFD/#2\uFFFD" }); @@ -2325,7 +2325,7 @@ describe('i18n support in the template compiler', () => { String.raw `{"\uFFFD#2\uFFFD\uFFFD/#2\uFFFD"}:TAG_IMG: is my logo #1 \`; } var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_461986953980355147$$APP_SPEC_TS__2$ = goog.getMsg("{$tagImg} is my logo #2 ", { "tagImg": "\uFFFD#1\uFFFD\uFFFD/#1\uFFFD" }); @@ -2371,7 +2371,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_8537814667662432133$$APP_SPEC_TS__0$ = goog.getMsg(" Root content {$startTagNgContainer} Nested content {$closeTagNgContainer}", { "startTagNgContainer": "\uFFFD*1:1\uFFFD\uFFFD#1:1\uFFFD", "closeTagNgContainer": "\uFFFD/#1:1\uFFFD\uFFFD/*1:1\uFFFD" @@ -2401,7 +2401,7 @@ describe('i18n support in the template compiler', () => { // that can be implemented in the future within FW-635. const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_6563391987554512024$$APP_SPEC_TS_0$ = goog.getMsg("Test"); $I18N_0$ = $MSG_EXTERNAL_6563391987554512024$$APP_SPEC_TS_0$; } @@ -2409,7 +2409,7 @@ describe('i18n support in the template compiler', () => { $I18N_0$ = $localize \`Test\`; } var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_6563391987554512024$$APP_SPEC_TS_1$ = goog.getMsg("Test"); $I18N_1$ = $MSG_EXTERNAL_6563391987554512024$$APP_SPEC_TS_1$; } @@ -2431,7 +2431,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_APP_SPEC_TS_1$ = goog.getMsg(" Hello {$startTagNgContainer}there{$closeTagNgContainer}", { "startTagNgContainer": "\uFFFD#2\uFFFD", "closeTagNgContainer": "\uFFFD/#2\uFFFD" }); $I18N_0$ = $MSG_APP_SPEC_TS_1$; } @@ -2467,7 +2467,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_APP_SPEC_TS_1$ = goog.getMsg(" Hello {$startTagNgContainer}there {$startTagStrong}!{$closeTagStrong}{$closeTagNgContainer}", { "startTagNgContainer": "\uFFFD#2\uFFFD", "startTagStrong": "\uFFFD#3\uFFFD", "closeTagStrong": "\uFFFD/#3\uFFFD", "closeTagNgContainer": "\uFFFD/#2\uFFFD" }); $I18N_0$ = $MSG_APP_SPEC_TS_1$; } @@ -2507,7 +2507,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_3308216566145348998$$APP_SPEC_TS___2$ = goog.getMsg("Content A"); $I18N_1$ = $MSG_EXTERNAL_3308216566145348998$$APP_SPEC_TS___2$; } else { @@ -2524,7 +2524,7 @@ describe('i18n support in the template compiler', () => { } } var $I18N_3$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_8349021389088127654$$APP_SPEC_TS__4$ = goog.getMsg("Content B"); $I18N_3$ = $MSG_EXTERNAL_8349021389088127654$$APP_SPEC_TS__4$; } else { @@ -2568,7 +2568,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_963542717423364282$$APP_SPEC_TS_0$ = goog.getMsg("\n Some text\n {$startTagSpan}Text inside span{$closeTagSpan}\n ", { "startTagSpan": "\uFFFD#3\uFFFD", "closeTagSpan": "\uFFFD/#3\uFFFD" @@ -2609,7 +2609,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_0$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$; } @@ -2645,7 +2645,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_4166854826696768832$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, single {'single quotes'} double {\"double quotes\"} other {other}}"); $I18N_0$ = $MSG_EXTERNAL_4166854826696768832$$APP_SPEC_TS_0$; } @@ -2667,7 +2667,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}"); $I18N_0$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS_0$; } @@ -2707,7 +2707,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_0$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_0$; } @@ -2718,7 +2718,7 @@ describe('i18n support in the template compiler', () => { "VAR_SELECT": "\uFFFD0\uFFFD" }); var $I18N_3$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS__3$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {other}}"); $I18N_3$ = $MSG_EXTERNAL_8806993169187953163$$APP_SPEC_TS__3$; } @@ -2743,7 +2743,7 @@ describe('i18n support in the template compiler', () => { } } var $I18N_5$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_1922743304863699161$$APP_SPEC_TS__5$ = goog.getMsg("{VAR_SELECT, select, 0 {no emails} 1 {one email} other {{INTERPOLATION} emails}}"); $I18N_5$ = $MSG_EXTERNAL_1922743304863699161$$APP_SPEC_TS__5$; } @@ -2801,7 +2801,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_2949673783721159566$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} other {{INTERPOLATION}}}"); $I18N_0$ = $MSG_EXTERNAL_2949673783721159566$$APP_SPEC_TS_0$; } @@ -2840,7 +2840,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_2417296354340576868$$APP_SPEC_TS_1$ = goog.getMsg("{VAR_SELECT, select, male {male - {START_BOLD_TEXT}male{CLOSE_BOLD_TEXT}} female {female {START_BOLD_TEXT}female{CLOSE_BOLD_TEXT}} other {{START_TAG_DIV}{START_ITALIC_TEXT}other{CLOSE_ITALIC_TEXT}{CLOSE_TAG_DIV}}}"); $I18N_1$ = $MSG_EXTERNAL_2417296354340576868$$APP_SPEC_TS_1$; } @@ -2857,7 +2857,7 @@ describe('i18n support in the template compiler', () => { "CLOSE_TAG_DIV": "" }); var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_5791551881115084301$$APP_SPEC_TS_0$ = goog.getMsg(" {$icu} {$startBoldText}Other content{$closeBoldText}{$startTagDiv}{$startItalicText}Another content{$closeItalicText}{$closeTagDiv}", { "startBoldText": "\uFFFD#2\uFFFD", "closeBoldText": "\uFFFD/#2\uFFFD", @@ -2911,7 +2911,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_6879461626778511059$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, male {male of age: {INTERPOLATION}} female {female} other {other}}"); $I18N_0$ = $MSG_EXTERNAL_6879461626778511059$$APP_SPEC_TS_0$; } @@ -2951,7 +2951,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_1$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_1$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_1$; } @@ -2962,7 +2962,7 @@ describe('i18n support in the template compiler', () => { "VAR_SELECT": "\uFFFD0\uFFFD" }); var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7068143081688428291$$APP_SPEC_TS_2$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}"); $I18N_2$ = $MSG_EXTERNAL_7068143081688428291$$APP_SPEC_TS_2$; } @@ -2973,7 +2973,7 @@ describe('i18n support in the template compiler', () => { "VAR_SELECT": "\uFFFD1\uFFFD" }); var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_2967249209167308918$$APP_SPEC_TS_0$ = goog.getMsg(" {$icu} {$icu_1} ", { "icu": $I18N_1$, "icu_1": $I18N_2$ @@ -3018,7 +3018,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_APP_SPEC_TS_1$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_1$ = $MSG_APP_SPEC_TS_1$; } @@ -3029,7 +3029,7 @@ describe('i18n support in the template compiler', () => { "VAR_SELECT": "\uFFFD0\uFFFD" }); var $I18N_2$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_APP_SPEC_TS_2$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_2$ = $MSG_APP_SPEC_TS_2$; } @@ -3040,7 +3040,7 @@ describe('i18n support in the template compiler', () => { "VAR_SELECT": "\uFFFD1\uFFFD" }); var $I18N_4$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_APP_SPEC_TS__4$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_4$ = $MSG_APP_SPEC_TS__4$; } @@ -3051,7 +3051,7 @@ describe('i18n support in the template compiler', () => { "VAR_SELECT": "\uFFFD0:1\uFFFD" }); var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_APP_SPEC_TS_0$ = goog.getMsg(" {$icu} {$startTagDiv} {$icu} {$closeTagDiv}{$startTagDiv_1} {$icu} {$closeTagDiv}", { "startTagDiv": "\uFFFD#2\uFFFD", "closeTagDiv": "[\uFFFD/#2\uFFFD|\uFFFD/#1:1\uFFFD\uFFFD/*3:1\uFFFD]", @@ -3126,7 +3126,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_343563413083115114$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT_1, select, male {male of age: {VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}} female {female} other {other}}"); $I18N_1$ = $MSG_EXTERNAL_343563413083115114$$APP_SPEC_TS_0$; } @@ -3138,7 +3138,7 @@ describe('i18n support in the template compiler', () => { "VAR_SELECT_1": "\uFFFD1\uFFFD" }); var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_3052001905251380936$$APP_SPEC_TS_3$ = goog.getMsg(" {$icu} ", { "icu": $I18N_1$ }); $I18N_0$ = $MSG_EXTERNAL_3052001905251380936$$APP_SPEC_TS_3$; } @@ -3181,7 +3181,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_6870293071705078389$$APP_SPEC_TS_1$ = goog.getMsg("{VAR_PLURAL, plural, =0 {zero} =2 {{INTERPOLATION} {VAR_SELECT, select, cat {cats} dog {dogs} other {animals}} !} other {other - {INTERPOLATION}}}"); $I18N_0$ = $MSG_EXTERNAL_6870293071705078389$$APP_SPEC_TS_1$; } @@ -3224,7 +3224,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_1$ = goog.getMsg("{VAR_SELECT, select, male {male} female {female} other {other}}"); $I18N_1$ = $MSG_EXTERNAL_7842238767399919809$$APP_SPEC_TS_1$; } @@ -3235,7 +3235,7 @@ describe('i18n support in the template compiler', () => { "VAR_SELECT": "\uFFFD0\uFFFD" }); var $I18N_3$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7068143081688428291$$APP_SPEC_TS__3$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other}}"); $I18N_3$ = $MSG_EXTERNAL_7068143081688428291$$APP_SPEC_TS__3$; } @@ -3246,7 +3246,7 @@ describe('i18n support in the template compiler', () => { "VAR_SELECT": "\uFFFD0:1\uFFFD" }); var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_1194472282609532229$$APP_SPEC_TS_0$ = goog.getMsg(" {$icu} {$startTagSpan} {$icu_1} {$closeTagSpan}", { "startTagSpan": "\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD", "closeTagSpan": "\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD", @@ -3310,7 +3310,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_1$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7825031864601787094$$APP_SPEC_TS_1$ = goog.getMsg("{VAR_SELECT, select, male {male {INTERPOLATION}} female {female {INTERPOLATION_1}} other {other}}"); $I18N_1$ = $MSG_EXTERNAL_7825031864601787094$$APP_SPEC_TS_1$; } @@ -3323,7 +3323,7 @@ describe('i18n support in the template compiler', () => { "INTERPOLATION_1": "\uFFFD2\uFFFD" }); var $I18N_3$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_2310343208266678305$$APP_SPEC_TS__3$ = goog.getMsg("{VAR_SELECT, select, 10 {ten} 20 {twenty} 30 {thirty} other {other: {INTERPOLATION}}}"); $I18N_3$ = $MSG_EXTERNAL_2310343208266678305$$APP_SPEC_TS__3$; } @@ -3335,7 +3335,7 @@ describe('i18n support in the template compiler', () => { "INTERPOLATION": "\uFFFD1:1\uFFFD" }); var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_7186042105600518133$$APP_SPEC_TS_0$ = goog.getMsg(" {$icu} {$startTagSpan} {$icu_1} {$closeTagSpan}", { "startTagSpan": "\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD", "closeTagSpan": "\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD", @@ -3400,7 +3400,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { const $MSG_EXTERNAL_6318060397235942326$$APP_SPEC_TS_0$ = goog.getMsg("{VAR_SELECT, select, male {male {PH_A}} female {female {PH_B}} other {other {PH_WITH_SPACES}}}"); $I18N_0$ = $MSG_EXTERNAL_6318060397235942326$$APP_SPEC_TS_0$; } @@ -3439,7 +3439,7 @@ describe('i18n support in the template compiler', () => { const output = String.raw ` var $I18N_0$; - if (ngI18nClosureMode) { + if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) { /** * @desc descA * @meaning meaningA diff --git a/packages/compiler/src/render3/view/template.ts b/packages/compiler/src/render3/view/template.ts index 4fd45693bb..4d1543f6b2 100644 --- a/packages/compiler/src/render3/view/template.ts +++ b/packages/compiler/src/render3/view/template.ts @@ -2070,7 +2070,7 @@ const NG_I18N_CLOSURE_MODE = 'ngI18nClosureMode'; * * ``` * var I18N_1; - * if (ngI18nClosureMode) { + * if (typeof ngI18nClosureMode !== undefined && ngI18nClosureMode) { * var MSG_EXTERNAL_XXX = goog.getMsg( * "Some message with {$interpolation}!", * { "interpolation": "\uFFFD0\uFFFD" } @@ -2098,10 +2098,9 @@ export function getTranslationDeclStmts( const statements: o.Statement[] = [ declareI18nVariable(variable), o.ifStmt( - o.variable(NG_I18N_CLOSURE_MODE), - createGoogleGetMsgStatements( - variable, message, closureVar, - i18nFormatPlaceholderNames(params, /* useCamelCase */ true)), + createClosureModeGuard(), createGoogleGetMsgStatements( + variable, message, closureVar, + i18nFormatPlaceholderNames(params, /* useCamelCase */ true)), createLocalizeStatements( variable, message, i18nFormatPlaceholderNames(params, /* useCamelCase */ false))), ]; @@ -2112,3 +2111,17 @@ export function getTranslationDeclStmts( return statements; } + +/** + * Create the expression that will be used to guard the closure mode block + * It is equivalent to: + * + * ``` + * typeof ngI18nClosureMode !== undefined && ngI18nClosureMode + * ``` + */ +function createClosureModeGuard(): o.BinaryOperatorExpr { + return o.typeofExpr(o.variable(NG_I18N_CLOSURE_MODE)) + .notIdentical(o.literal('undefined', o.STRING_TYPE)) + .and(o.variable(NG_I18N_CLOSURE_MODE)); +}