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

Commit f742394

Browse files
committed
fix(zone): consistent access to __symbol__ to work with closure
We used to access Zone.__symbol__ and other times Zone[‘__symbol__’]. This confuses closure as it inconsistently renames symbols which breaks code.
1 parent 2e4cca5 commit f742394

File tree

9 files changed

+9
-9
lines changed

9 files changed

+9
-9
lines changed

Diff for: lib/browser/webapis-media-query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
return;
1515
}
1616
const patchEventTargetMethods =
17-
(Zone as any)[(Zone as any)['__symbol__']('patchEventTargetMethods')];
17+
(Zone as any)[(Zone as any).__symbol__('patchEventTargetMethods')];
1818
patchEventTargetMethods(
1919
_global['MediaQueryList'].prototype, 'addListener', 'removeListener',
2020
(self: any, args: any[]) => {

Diff for: lib/browser/webapis-notification.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
if (!desc || !desc.configurable) {
1919
return;
2020
}
21-
const patchOnProperties = (Zone as any)[(Zone as any)['__symbol__']('patchOnProperties')];
21+
const patchOnProperties = (Zone as any)[(Zone as any).__symbol__('patchOnProperties')];
2222
patchOnProperties(Notification.prototype, null);
2323
}
2424
})(typeof window === 'object' && window || typeof self === 'object' && self || global);

Diff for: lib/extra/bluebird.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
((_global: any) => {
9-
const __symbol__ = (Zone as any)['__symbol__'];
9+
const __symbol__ = (Zone as any).__symbol__;
1010
// TODO: @JiaLiPassion, we can automatically patch bluebird
1111
// if global.Promise = Bluebird, but sometimes in nodejs,
1212
// global.Promise is not Bluebird, and Bluebird is just be

Diff for: lib/zone-spec/fake-async-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
private _microtasks: Function[] = [];
8787
private _lastError: Error = null;
8888
private _uncaughtPromiseErrors: {rejection: any}[] =
89-
(Promise as any)[(Zone as any)['__symbol__']('uncaughtPromiseErrors')];
89+
(Promise as any)[(Zone as any).__symbol__('uncaughtPromiseErrors')];
9090

9191
pendingPeriodicTimers: number[] = [];
9292
pendingTimers: number[] = [];

Diff for: lib/zone-spec/long-stack-trace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function renderLongStackTrace(frames: LongStackTrace[], stack: string): string {
8383
if (!error) {
8484
return undefined;
8585
}
86-
const task = (error as any)[(Zone as any)['__symbol__']('currentTask')];
86+
const task = (error as any)[(Zone as any).__symbol__('currentTask')];
8787
const trace = task && task.data && task.data[creationTrace];
8888
if (!trace) {
8989
return error.stack;

Diff for: test/browser/element.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('element', function() {
9292
* For now we are choosing to ignore it and assume that this arrises in tests only.
9393
* As an added measure we make sure that all jasmine tests always run in a task. See: jasmine.ts
9494
*/
95-
global[(Zone as any)['__symbol__']('setTimeout')](() => {
95+
global[(Zone as any).__symbol__('setTimeout')](() => {
9696
let log = '';
9797
button.addEventListener('click', () => {
9898
Zone.current.scheduleMicroTask('test', () => log += 'microtask;');

Diff for: test/common/Error.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ describe('ZoneAwareError', () => {
159159

160160
it('should copy customized NativeError properties to ZoneAwareError', () => {
161161
const spy = jasmine.createSpy('errorCustomFunction');
162-
const NativeError = (global as any)[(Zone as any)['__symbol__']('Error')];
162+
const NativeError = (global as any)[(Zone as any).__symbol__('Error')];
163163
NativeError.customFunction = function(args: any) {
164164
spy(args);
165165
};

Diff for: test/extra/bluebird.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('bluebird promise', () => {
1616
BluebirdPromise = require('bluebird');
1717
// import bluebird patch
1818
require('../../lib/extra/bluebird');
19-
const patchBluebird = (Zone as any)[(Zone as any)['__symbol__']('bluebird')];
19+
const patchBluebird = (Zone as any)[(Zone as any).__symbol__('bluebird')];
2020
patchBluebird(BluebirdPromise);
2121
});
2222

Diff for: test/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ __karma__.loaded = function() {};
1717

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

0 commit comments

Comments
 (0)