diff --git a/aio/content/guide/browser-support.md b/aio/content/guide/browser-support.md index 152ced5362..1d201506fd 100644 --- a/aio/content/guide/browser-support.md +++ b/aio/content/guide/browser-support.md @@ -539,7 +539,7 @@ For example: */ // __Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame // __Zone_disable_on_property = true; // disable patch onProperty such as onclick - // __zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames + // __zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames /* * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js diff --git a/aio/tools/examples/shared/boilerplate/cli/src/polyfills.ts b/aio/tools/examples/shared/boilerplate/cli/src/polyfills.ts index 2f258e56c6..cf065a94b9 100644 --- a/aio/tools/examples/shared/boilerplate/cli/src/polyfills.ts +++ b/aio/tools/examples/shared/boilerplate/cli/src/polyfills.ts @@ -41,9 +41,11 @@ * * The following flags will work for all browsers. * - * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame + * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch + * requestAnimationFrame * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick - * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames + * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch + * specified eventNames * * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js * with the following flag, it will bypass `zone.js` patch for IE/Edge diff --git a/integration/cli-hello-world-ivy-compat/src/polyfills.ts b/integration/cli-hello-world-ivy-compat/src/polyfills.ts index a6d34ea67a..615eeed0ca 100644 --- a/integration/cli-hello-world-ivy-compat/src/polyfills.ts +++ b/integration/cli-hello-world-ivy-compat/src/polyfills.ts @@ -65,7 +65,7 @@ * * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick - * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames + * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames * * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js * with the following flag, it will bypass `zone.js` patch for IE/Edge diff --git a/integration/cli-hello-world-ivy-minimal/src/polyfills.ts b/integration/cli-hello-world-ivy-minimal/src/polyfills.ts index a6d34ea67a..615eeed0ca 100644 --- a/integration/cli-hello-world-ivy-minimal/src/polyfills.ts +++ b/integration/cli-hello-world-ivy-minimal/src/polyfills.ts @@ -65,7 +65,7 @@ * * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick - * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames + * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames * * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js * with the following flag, it will bypass `zone.js` patch for IE/Edge diff --git a/integration/cli-hello-world/src/polyfills.ts b/integration/cli-hello-world/src/polyfills.ts index a6d34ea67a..615eeed0ca 100644 --- a/integration/cli-hello-world/src/polyfills.ts +++ b/integration/cli-hello-world/src/polyfills.ts @@ -65,7 +65,7 @@ * * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick - * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames + * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames * * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js * with the following flag, it will bypass `zone.js` patch for IE/Edge diff --git a/packages/platform-browser/src/dom/events/dom_events.ts b/packages/platform-browser/src/dom/events/dom_events.ts index 051a63d339..59b041cf04 100644 --- a/packages/platform-browser/src/dom/events/dom_events.ts +++ b/packages/platform-browser/src/dom/events/dom_events.ts @@ -34,24 +34,22 @@ const NATIVE_REMOVE_LISTENER = 'removeEventListener'; const stopSymbol = '__zone_symbol__propagationStopped'; const stopMethodSymbol = '__zone_symbol__stopImmediatePropagation'; - -const blackListedMap = (() => { - const blackListedEvents: string[] = - (typeof Zone !== 'undefined') && (Zone as any)[__symbol__('BLACK_LISTED_EVENTS')]; - if (blackListedEvents) { - const res: {[eventName: string]: string} = {}; - blackListedEvents.forEach(eventName => { res[eventName] = eventName; }); - return res; +const unpatchedMap: {[key: string]: string}|undefined = (() => { + const unpatchedEvents = + (typeof Zone !== 'undefined') && (Zone as any)[__symbol__('UNPATCHED_EVENTS')]; + if (unpatchedEvents) { + const unpatchedEventMap: {[eventName: string]: string} = {}; + unpatchedEvents.forEach((eventName: string) => { unpatchedEventMap[eventName] = eventName; }); + return unpatchedEventMap; } return undefined; })(); - -const isBlackListedEvent = function(eventName: string) { - if (!blackListedMap) { +const isUnpatchedEvent = function(eventName: string) { + if (!unpatchedMap) { return false; } - return blackListedMap.hasOwnProperty(eventName); + return unpatchedMap.hasOwnProperty(eventName); }; interface TaskData { @@ -160,7 +158,7 @@ export class DomEventsPlugin extends EventManagerPlugin { let callback: EventListener = handler as EventListener; // if zonejs is loaded and current zone is not ngZone // we keep Zone.current on target for later restoration. - if (zoneJsLoaded && (!NgZone.isInAngularZone() || isBlackListedEvent(eventName))) { + if (zoneJsLoaded && (!NgZone.isInAngularZone() || isUnpatchedEvent(eventName))) { let symbolName = symbolNames[eventName]; if (!symbolName) { symbolName = symbolNames[eventName] = __symbol__(ANGULAR + eventName + FALSE); @@ -171,7 +169,7 @@ export class DomEventsPlugin extends EventManagerPlugin { taskDatas = (element as any)[symbolName] = []; } - const zone = isBlackListedEvent(eventName) ? Zone.root : Zone.current; + const zone = isUnpatchedEvent(eventName) ? Zone.root : Zone.current; if (taskDatas.length === 0) { taskDatas.push({zone: zone, handler: callback}); } else { diff --git a/test-events.js b/test-events.js index e32e0a537e..6f214fa50d 100644 --- a/test-events.js +++ b/test-events.js @@ -6,4 +6,4 @@ * found in the LICENSE file at https://angular.io/license */ -Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')] = ['scroll']; \ No newline at end of file +Zone[Zone.__symbol__('UNPATCHED_EVENTS')] = ['scroll'];