Skip to content

Instantly share code, notes, and snippets.

@pilgreen
Last active December 29, 2016 22:42
Show Gist options
  • Save pilgreen/d9b94ec71416c4badba9a57b294d13e6 to your computer and use it in GitHub Desktop.
Save pilgreen/d9b94ec71416c4badba9a57b294d13e6 to your computer and use it in GitHub Desktop.
A small copy of Polymer's dom-module.
<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