HTML DOM : How to get the whole list of registered event handlers? [duplicate]
For debugging purpose and memory leak, I'd like to have the full list of reg开发者_运维问答istered event handlers. There's this nice visual tool but a plain text list would be welcomed.
As the mentioned link says, there is no JavaScript API to retrieve all registered listeners. So, for testing purposes you might try overriding the EventTarget.prototype.addEventListener/removeEventListener methods and storing their arguments in your own storage to inspect later.
On a similar note, you can use the Chrome Developer Tools to examine currently registered listeners for a particular node (or the node chain up to the document root) in the Elements panel ("Event Listeners" section in the sidebar.)
精彩评论