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

Commit

Permalink
fix(zone): consistent access to __symbol__ to work with closure
Browse files Browse the repository at this point in the history
We used to access Zone.__symbol__ and other times Zone[‘__symbol__’]. 
This confuses closure as it inconsistently renames symbols which breaks
code.
  • Loading branch information
mhevery committed Mar 15, 2017
1 parent 2e4cca5 commit f742394
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/browser/webapis-media-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
return;
}
const patchEventTargetMethods =
(Zone as any)[(Zone as any)['__symbol__']('patchEventTargetMethods')];
(Zone as any)[(Zone as any).__symbol__('patchEventTargetMethods')];
patchEventTargetMethods(
_global['MediaQueryList'].prototype, 'addListener', 'removeListener',
(self: any, args: any[]) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/webapis-notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
if (!desc || !desc.configurable) {
return;
}
const patchOnProperties = (Zone as any)[(Zone as any)['__symbol__']('patchOnProperties')];
const patchOnProperties = (Zone as any)[(Zone as any).__symbol__('patchOnProperties')];
patchOnProperties(Notification.prototype, null);
}
})(typeof window === 'object' && window || typeof self === 'object' && self || global);
2 changes: 1 addition & 1 deletion lib/extra/bluebird.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
((_global: any) => {
const __symbol__ = (Zone as any)['__symbol__'];
const __symbol__ = (Zone as any).__symbol__;
// TODO: @JiaLiPassion, we can automatically patch bluebird
// if global.Promise = Bluebird, but sometimes in nodejs,
// global.Promise is not Bluebird, and Bluebird is just be
Expand Down
2 changes: 1 addition & 1 deletion lib/zone-spec/fake-async-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
private _microtasks: Function[] = [];
private _lastError: Error = null;
private _uncaughtPromiseErrors: {rejection: any}[] =
(Promise as any)[(Zone as any)['__symbol__']('uncaughtPromiseErrors')];
(Promise as any)[(Zone as any).__symbol__('uncaughtPromiseErrors')];

pendingPeriodicTimers: number[] = [];
pendingTimers: number[] = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/zone-spec/long-stack-trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function renderLongStackTrace(frames: LongStackTrace[], stack: string): string {
if (!error) {
return undefined;
}
const task = (error as any)[(Zone as any)['__symbol__']('currentTask')];
const task = (error as any)[(Zone as any).__symbol__('currentTask')];
const trace = task && task.data && task.data[creationTrace];
if (!trace) {
return error.stack;
Expand Down
2 changes: 1 addition & 1 deletion test/browser/element.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('element', function() {
* For now we are choosing to ignore it and assume that this arrises in tests only.
* As an added measure we make sure that all jasmine tests always run in a task. See: jasmine.ts
*/
global[(Zone as any)['__symbol__']('setTimeout')](() => {
global[(Zone as any).__symbol__('setTimeout')](() => {
let log = '';
button.addEventListener('click', () => {
Zone.current.scheduleMicroTask('test', () => log += 'microtask;');
Expand Down
2 changes: 1 addition & 1 deletion test/common/Error.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe('ZoneAwareError', () => {

it('should copy customized NativeError properties to ZoneAwareError', () => {
const spy = jasmine.createSpy('errorCustomFunction');
const NativeError = (global as any)[(Zone as any)['__symbol__']('Error')];
const NativeError = (global as any)[(Zone as any).__symbol__('Error')];
NativeError.customFunction = function(args: any) {
spy(args);
};
Expand Down
2 changes: 1 addition & 1 deletion test/extra/bluebird.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('bluebird promise', () => {
BluebirdPromise = require('bluebird');
// import bluebird patch
require('../../lib/extra/bluebird');
const patchBluebird = (Zone as any)[(Zone as any)['__symbol__']('bluebird')];
const patchBluebird = (Zone as any)[(Zone as any).__symbol__('bluebird')];
patchBluebird(BluebirdPromise);
});

Expand Down
2 changes: 1 addition & 1 deletion test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ __karma__.loaded = function() {};

System.config({defaultJSExtensions: true});
let browserPatchedPromise = null;
if ((window as any)[(Zone as any)['__symbol__']('setTimeout')]) {
if ((window as any)[(Zone as any).__symbol__('setTimeout')]) {
browserPatchedPromise = Promise.resolve('browserPatched');
} else {
// this means that Zone has not patched the browser yet, which means we must be running in
Expand Down

0 comments on commit f742394

Please sign in to comment.