Last active
February 25, 2019 21:40
-
-
Save athlonUA/c33847b882d0e13a692f7d7a6a26b449 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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