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:
Steve Sanderson 2019-09-26 13:32:24 +01:00 committed by Artak
parent 3cd4726c76
commit 31ee4a8daf
1 changed files with 0 additions and 14 deletions

View File

@ -69,7 +69,6 @@ export class EventDelegator {
const elementEventInfos = this.getEventHandlerInfosForElement(element, false);
if (elementEventInfos) {
elementEventInfos.removeHandler(info.eventName);
this.cleanEventHandlerInfosForElement(element);
}
}
}
@ -121,13 +120,6 @@ export class EventDelegator {
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
@ -230,12 +222,6 @@ class EventHandlerInfosForElement {
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 {