Last active
December 29, 2016 22:42
-
-
Save pilgreen/d9b94ec71416c4badba9a57b294d13e6 to your computer and use it in GitHub Desktop.
A small copy of Polymer's dom-module.
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
<script> | |
class DomModule extends HTMLElement { | |
constructor() { | |
super(); | |
} | |
connectedCallback() { | |
this.register(); | |
} | |
register() { | |
this.constructor.loaded[this.id] = this; | |
} | |
static import(id, selector) { | |
let m = this.loaded[id]; | |
if(m && selector) { | |
return m.querySelector(selector); | |
} | |
return m; | |
} | |
} | |
DomModule.loaded = {}; | |
customElements.define('dom-module', DomModule); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment