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

Commit

Permalink
fix(closure): avoid property renaming on globals
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Dec 15, 2016
1 parent f522e1b commit af14646
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/common/utils.ts
Expand Up @@ -14,7 +14,7 @@

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

export function bindArguments(args: any[], source: string): any[] {
Expand Down
14 changes: 10 additions & 4 deletions lib/zone.ts
Expand Up @@ -6,6 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/

/*
* Suppress closure compiler errors about unknown 'global' variable
* @fileoverview
* @suppress {undefinedVars}
*/

/**
* Zone is a mechanism for intercepting and keeping track of asynchronous work.
*
Expand Down Expand Up @@ -540,7 +546,7 @@ type AmbientZone = Zone;
type AmbientZoneDelegate = ZoneDelegate;

const Zone: ZoneType = (function(global: any) {
if (global.Zone) {
if (global['Zone']) {
throw new Error('Zone already loaded.');
}

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

const NativePromise = global[__symbol__('Promise')] = global.Promise;
global.Promise = ZoneAwarePromise;
const NativePromise = global[__symbol__('Promise')] = global['Promise'];
global['Promise'] = ZoneAwarePromise;
function patchThen(NativePromise) {
const NativePromiseProtototype = NativePromise.prototype;
const NativePromiseThen = NativePromiseProtototype[__symbol__('then')] =
Expand Down Expand Up @@ -1428,5 +1434,5 @@ const Zone: ZoneType = (function(global: any) {
// Cause the error to extract the stack frames.
detectZone.runTask(detectZone.scheduleMacroTask('detect', detectRunFn, null, () => null, null));

return global.Zone = Zone;
return global['Zone'] = Zone;
})(typeof window === 'object' && window || typeof self === 'object' && self || global);

0 comments on commit af14646

Please sign in to comment.