Created
July 26, 2016 17:56
-
-
Save ryanmorr/0e5cd1c10a16050ca6880777972dc711 to your computer and use it in GitHub Desktop.
Event delegation in 3 lines
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
function delegate(context, type, selector, fn) { | |
context.addEventListener(type, (e) => fn(e, e.target.closest(selector))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment