-
-
Save amit08255/d29e04061cc4be0e219269f3a87d199f to your computer and use it in GitHub Desktop.
intercept *.addEventListener for debugging
This file contains 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
// http://stackoverflow.com/questions/4787698/failure-to-override-elements-addeventlistener-in-firefox | |
(function() { | |
Error.stackTraceLimit = Infinity; | |
var _interfaces = Object.getOwnPropertyNames(window).filter(function(i) { | |
return /^HTML/.test(i); | |
}).map(function(i) { | |
return window[i]; | |
}); | |
// var _interfaces = [ HTMLDivElement, HTMLImageElement, HTMLUListElement, HTMLElement, HTMLDocument ]; | |
for (var i = 0; i < _interfaces.length; i++) { | |
(function(original) { | |
_interfaces[i].prototype.addEventListener = function(type, listener, useCapture) { | |
console.log('addEventListener ' + type, listener, useCapture); | |
console.trace(); | |
console.log('--------'); | |
return original.apply(this, arguments); | |
} | |
})(_interfaces[i].prototype.addEventListener); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment