Skip to content

Instantly share code, notes, and snippets.

@autioch
Created May 5, 2016 13:51
Show Gist options
  • Save autioch/03fe3c111bdfb5351acfa3d16f153cb7 to your computer and use it in GitHub Desktop.
Save autioch/03fe3c111bdfb5351acfa3d16f153cb7 to your computer and use it in GitHub Desktop.
/* 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