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

Commit

Permalink
env: change BLACK_LISTED_EVENTS to DISABLE_EVENTS
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion authored and IgorMinar committed Feb 28, 2019
1 parent 2ad936b commit 9c65d25
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
15 changes: 15 additions & 0 deletions lib/browser/api-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,19 @@ Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
api.patchMethod = patchMethod;
api.bindArguments = bindArguments;
api.patchMacroTask = patchMacroTask;
// In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to
// define which events will not be patched by `Zone.js`.
// In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep
// the name consistent with angular repo.
// The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for
// backwards compatibility.
const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS');
const SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS');
if (global[SYMBOL_UNPATCHED_EVENTS]) {
global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS];
}
if (global[SYMBOL_BLACK_LISTED_EVENTS]) {
(Zone as any)[SYMBOL_BLACK_LISTED_EVENTS] = (Zone as any)[SYMBOL_UNPATCHED_EVENTS] =
global[SYMBOL_BLACK_LISTED_EVENTS];
}
});
4 changes: 0 additions & 4 deletions lib/browser/browser-legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ Zone.__load_patch('registerElement', (global: any, Zone: ZoneType, api: _ZonePri
});

Zone.__load_patch('EventTargetLegacy', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS');
if (global[SYMBOL_BLACK_LISTED_EVENTS]) {
(Zone as any)[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS];
}
eventTargetLegacyPatch(global, api);
propertyDescriptorLegacyPatch(api, global);
});
6 changes: 0 additions & 6 deletions lib/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ Zone.__load_patch('blocking', (global: any, Zone: ZoneType) => {
});

Zone.__load_patch('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
// load blackListEvents from global
const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS');
if (global[SYMBOL_BLACK_LISTED_EVENTS]) {
(Zone as any)[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS];
}

patchEvent(global, api);
eventTargetPatch(global, api);
// patch XMLHttpRequestEventTarget's addEventListener/removeEventListener
Expand Down
2 changes: 1 addition & 1 deletion test/test_fake_polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ Object.defineProperties(TestTarget.prototype, {
global['__Zone_ignore_on_properties'] =
[{target: TestTarget.prototype, ignoreProperties: ['prop1']}];
global['__zone_symbol__FakeAsyncTestMacroTask'] = [{source: 'TestClass.myTimeout'}];
global['__zone_symbol__BLACK_LISTED_EVENTS'] = ['scroll'];
global['__zone_symbol__UNPATCHED_EVENTS'] = ['scroll'];
})(typeof window === 'object' && window || typeof self === 'object' && self || global);

0 comments on commit 9c65d25

Please sign in to comment.