2

For debugging purpose and memory leak, I'd like to have the full list of registered event handlers. There's this nice visual tool but a plain text list would be welcomed.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Marc Polizzi
  • 9,275
  • 3
  • 36
  • 61

1 Answers1

3

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.)

Alexander Pavlov
  • 31,598
  • 5
  • 67
  • 93