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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user