fix(core): ensure that `ngI18nClosureMode` is guarded (#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.)

PR Close #34211
This commit is contained in:
Pete Bacon Darwin 2019-12-03 08:47:12 +00:00 committed by Miško Hevery
parent cca2616637
commit bc7cde0f01
1 changed files with 2 additions and 1 deletions

View File

@ -49,7 +49,8 @@ export function _localeFactory(locale?: string): string {
* * Ivy enabled: use `$localize.locale`
*/
export function getGlobalLocale(): string {
if (ngI18nClosureMode && typeof goog !== 'undefined' && goog.LOCALE !== 'en') {
if (typeof ngI18nClosureMode !== 'undefined' && ngI18nClosureMode &&
typeof goog !== 'undefined' && goog.LOCALE !== 'en') {
// * The default `goog.LOCALE` value is `en`, while Angular used `en-US`.
// * In order to preserve backwards compatibility, we use Angular default value over
// Closure Compiler's one.