Skip to content

Instantly share code, notes, and snippets.

@matthewpizza
Created August 7, 2020 22:17
Show Gist options
  • Save matthewpizza/78d4de4c403092b3bc7e151e50d8835d to your computer and use it in GitHub Desktop.
Save matthewpizza/78d4de4c403092b3bc7e151e50d8835d to your computer and use it in GitHub Desktop.
For future me
const logAllEventsForEl = (el) => {
Object.keys(el.__proto__.__proto__)
.reduce((eventNames, key) => {
if (key.startsWith('on')) {
return [...eventNames, key.substr(2)]
}
return eventNames
}, [])
.map(eventName => {
el.addEventListener(eventName, event => console.log(event.type))
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment