Last active
March 24, 2017 23:22
-
-
Save hagata/8c8b1a6cfea83a815436be8ff69baa36 to your computer and use it in GitHub Desktop.
Basic Module/Component loader. Starts up new instances of classes based on data attributes on elements in the DOM.
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
| import {exampleModue} from '../modules/exampleModue'; | |
| const modules = { | |
| exampleModue: exampleModue | |
| }; | |
| function loadModules() { | |
| const moduleNodes = document.querySelectorAll('[data-component]'); | |
| console.log('Loading', modules); | |
| for (const node of moduleNodes) { | |
| const moduleName = node.dataset.component; | |
| appModules[moduleName] = new modules[moduleName](node); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment