Created
August 7, 2020 22:17
-
-
Save matthewpizza/78d4de4c403092b3bc7e151e50d8835d to your computer and use it in GitHub Desktop.
For future me
This file contains 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
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