refactor: rename unpatched event flag in Zone from `BLACK_LISTED_EVENTS` to `UNPATCHED_EVENTS` (#29617)
Closes #28529 PR Close #29617
This commit is contained in:
parent
442f323a32
commit
53d13c3fc6
|
@ -539,7 +539,7 @@ For example:
|
||||||
*/
|
*/
|
||||||
// __Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
// __Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
|
||||||
// __Zone_disable_on_property = true; // disable patch onProperty such as onclick
|
// __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
|
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
|
||||||
|
|
|
@ -41,9 +41,11 @@
|
||||||
*
|
*
|
||||||
* The following flags will work for all browsers.
|
* 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_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
|
* 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
|
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
*
|
*
|
||||||
* (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_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
|
* 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
|
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
*
|
*
|
||||||
* (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_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
|
* 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
|
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
*
|
*
|
||||||
* (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_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
|
* 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
|
* with the following flag, it will bypass `zone.js` patch for IE/Edge
|
||||||
|
|
|
@ -34,24 +34,22 @@ const NATIVE_REMOVE_LISTENER = 'removeEventListener';
|
||||||
const stopSymbol = '__zone_symbol__propagationStopped';
|
const stopSymbol = '__zone_symbol__propagationStopped';
|
||||||
const stopMethodSymbol = '__zone_symbol__stopImmediatePropagation';
|
const stopMethodSymbol = '__zone_symbol__stopImmediatePropagation';
|
||||||
|
|
||||||
|
const unpatchedMap: {[key: string]: string}|undefined = (() => {
|
||||||
const blackListedMap = (() => {
|
const unpatchedEvents =
|
||||||
const blackListedEvents: string[] =
|
(typeof Zone !== 'undefined') && (Zone as any)[__symbol__('UNPATCHED_EVENTS')];
|
||||||
(typeof Zone !== 'undefined') && (Zone as any)[__symbol__('BLACK_LISTED_EVENTS')];
|
if (unpatchedEvents) {
|
||||||
if (blackListedEvents) {
|
const unpatchedEventMap: {[eventName: string]: string} = {};
|
||||||
const res: {[eventName: string]: string} = {};
|
unpatchedEvents.forEach((eventName: string) => { unpatchedEventMap[eventName] = eventName; });
|
||||||
blackListedEvents.forEach(eventName => { res[eventName] = eventName; });
|
return unpatchedEventMap;
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
const isUnpatchedEvent = function(eventName: string) {
|
||||||
const isBlackListedEvent = function(eventName: string) {
|
if (!unpatchedMap) {
|
||||||
if (!blackListedMap) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return blackListedMap.hasOwnProperty(eventName);
|
return unpatchedMap.hasOwnProperty(eventName);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface TaskData {
|
interface TaskData {
|
||||||
|
@ -160,7 +158,7 @@ export class DomEventsPlugin extends EventManagerPlugin {
|
||||||
let callback: EventListener = handler as EventListener;
|
let callback: EventListener = handler as EventListener;
|
||||||
// if zonejs is loaded and current zone is not ngZone
|
// if zonejs is loaded and current zone is not ngZone
|
||||||
// we keep Zone.current on target for later restoration.
|
// 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];
|
let symbolName = symbolNames[eventName];
|
||||||
if (!symbolName) {
|
if (!symbolName) {
|
||||||
symbolName = symbolNames[eventName] = __symbol__(ANGULAR + eventName + FALSE);
|
symbolName = symbolNames[eventName] = __symbol__(ANGULAR + eventName + FALSE);
|
||||||
|
@ -171,7 +169,7 @@ export class DomEventsPlugin extends EventManagerPlugin {
|
||||||
taskDatas = (element as any)[symbolName] = [];
|
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) {
|
if (taskDatas.length === 0) {
|
||||||
taskDatas.push({zone: zone, handler: callback});
|
taskDatas.push({zone: zone, handler: callback});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')] = ['scroll'];
|
Zone[Zone.__symbol__('UNPATCHED_EVENTS')] = ['scroll'];
|
||||||
|
|
Loading…
Reference in New Issue