Skip to content

Instantly share code, notes, and snippets.

@athlonUA
Last active February 25, 2019 21:40
Show Gist options
  • Save athlonUA/c33847b882d0e13a692f7d7a6a26b449 to your computer and use it in GitHub Desktop.
Save athlonUA/c33847b882d0e13a692f7d7a6a26b449 to your computer and use it in GitHub Desktop.
(function() {
Element.prototype.eventListenerList = {};
Element.prototype._addEventListener = Element.prototype.addEventListener;
Element.prototype.addEventListener = function(type, listener) {
this._addEventListener(type, listener);
if (!this.eventListenerList[this.id]) {
this.eventListenerList[this.id] = {};
}
if (!this.eventListenerList[this.id][type]) {
this.eventListenerList[this.id][type] = 0;
}
this.eventListenerList[this.id][type] += 1;
};
return (getEventListeners = target => target.eventListenerList[target.id]);
})();
const submit = document.getElementById('submit');
submit.addEventListener('click', _ => {});
submit.addEventListener('hover', _ => {});
setInterval(_ => {
submit.addEventListener('click', _ => {});
console.log(getEventListeners(submit));
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment