Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit af14646

Browse files
committed
fix(closure): avoid property renaming on globals
1 parent f522e1b commit af14646

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Diff for: lib/common/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
// Hack since TypeScript isn't compiling this for a worker.
1616
declare const WorkerGlobalScope;
17-
export const zoneSymbol: (name: string) => string = Zone['__symbol__'];
17+
export const zoneSymbol: (name: string) => string = (n) => `__zone_symbol__${n}`;
1818
const _global = typeof window === 'object' && window || typeof self === 'object' && self || global;
1919

2020
export function bindArguments(args: any[], source: string): any[] {

Diff for: lib/zone.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
/*
10+
* Suppress closure compiler errors about unknown 'global' variable
11+
* @fileoverview
12+
* @suppress {undefinedVars}
13+
*/
14+
915
/**
1016
* Zone is a mechanism for intercepting and keeping track of asynchronous work.
1117
*
@@ -540,7 +546,7 @@ type AmbientZone = Zone;
540546
type AmbientZoneDelegate = ZoneDelegate;
541547

542548
const Zone: ZoneType = (function(global: any) {
543-
if (global.Zone) {
549+
if (global['Zone']) {
544550
throw new Error('Zone already loaded.');
545551
}
546552

@@ -1214,8 +1220,8 @@ const Zone: ZoneType = (function(global: any) {
12141220
ZoneAwarePromise['race'] = ZoneAwarePromise.race;
12151221
ZoneAwarePromise['all'] = ZoneAwarePromise.all;
12161222

1217-
const NativePromise = global[__symbol__('Promise')] = global.Promise;
1218-
global.Promise = ZoneAwarePromise;
1223+
const NativePromise = global[__symbol__('Promise')] = global['Promise'];
1224+
global['Promise'] = ZoneAwarePromise;
12191225
function patchThen(NativePromise) {
12201226
const NativePromiseProtototype = NativePromise.prototype;
12211227
const NativePromiseThen = NativePromiseProtototype[__symbol__('then')] =
@@ -1428,5 +1434,5 @@ const Zone: ZoneType = (function(global: any) {
14281434
// Cause the error to extract the stack frames.
14291435
detectZone.runTask(detectZone.scheduleMacroTask('detect', detectRunFn, null, () => null, null));
14301436

1431-
return global.Zone = Zone;
1437+
return global['Zone'] = Zone;
14321438
})(typeof window === 'object' && window || typeof self === 'object' && self || global);

0 commit comments

Comments
 (0)