Simplify: once we start tracking event info for a given element, there's no real value in deleting that tracking info later
This commit is contained in:
parent
3cd4726c76
commit
31ee4a8daf
|
|
@ -69,7 +69,6 @@ export class EventDelegator {
|
||||||
const elementEventInfos = this.getEventHandlerInfosForElement(element, false);
|
const elementEventInfos = this.getEventHandlerInfosForElement(element, false);
|
||||||
if (elementEventInfos) {
|
if (elementEventInfos) {
|
||||||
elementEventInfos.removeHandler(info.eventName);
|
elementEventInfos.removeHandler(info.eventName);
|
||||||
this.cleanEventHandlerInfosForElement(element);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -121,13 +120,6 @@ export class EventDelegator {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private cleanEventHandlerInfosForElement(element: Element) {
|
|
||||||
const existingValue = this.getEventHandlerInfosForElement(element, false);
|
|
||||||
if (existingValue && existingValue.isEmpty()) {
|
|
||||||
delete element[this.eventsCollectionKey];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Responsible for adding and removing the global listener when the number of listeners
|
// Responsible for adding and removing the global listener when the number of listeners
|
||||||
|
|
@ -230,12 +222,6 @@ class EventHandlerInfosForElement {
|
||||||
|
|
||||||
return this.stopBubblingFlags ? this.stopBubblingFlags[eventName] : false;
|
return this.stopBubblingFlags ? this.stopBubblingFlags[eventName] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public isEmpty(): boolean {
|
|
||||||
return Object.getOwnPropertyNames(this.handlers).length === 0
|
|
||||||
&& (!this.preventDefaultFlags || Object.getOwnPropertyNames(this.preventDefaultFlags).length === 0)
|
|
||||||
&& (!this.stopBubblingFlags || Object.getOwnPropertyNames(this.stopBubblingFlags).length === 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EventHandlerInfo {
|
interface EventHandlerInfo {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue