Created
May 5, 2016 13:51
-
-
Save autioch/03fe3c111bdfb5351acfa3d16f153cb7 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
/* jQuery way */ | |
$('*') | |
.filter(function(){ | |
return !!$._data( this, 'events'); | |
}) | |
.get() | |
.reduce(function(dict, el){ | |
dict[el.className] = Object.keys($._data( el, 'events')).sort().join(', ') | |
return dict; | |
}, {}); | |
/* Developer tools way */ | |
Array | |
.from(document.querySelectorAll('*')) | |
.filter(el => !!Object.keys(getEventListeners(el)).length) | |
.sort() | |
.reduce(function(dict, el) { | |
/* SVG className is an object, so we have to use getAttribute*/ | |
const classAttr = el.getAttribute('class'); | |
const className = classAttr ? '.' + classAttr.replace(/ /g, '.') : ''; | |
dict[el.tagName + className] = Object.keys(getEventListeners(el)).sort().join(', '); | |
return dict; | |
}, {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment