Created
March 30, 2016 16:55
-
-
Save dawnerd/1e4eb8c3c2df24678608528dee606cb8 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
class Domodule { | |
constructor(el) { | |
this.el = el; | |
this.els = {}; | |
for (const action of this.find('[data-action]')) { | |
action.addEventListener( | |
action.dataset.actionType || 'click', | |
this[action.dataset.action].bind(this) | |
); | |
} | |
for (const named of this.find('[data-name]')) { | |
this.els[named.dataset.name] = named; | |
} | |
// NOTE: Do we want to return the class instance or the el? | |
return this; | |
} | |
find(selector) { | |
return this.el.querySelectorAll(selector); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment