Skip to content

Instantly share code, notes, and snippets.

@iammerrick
Created April 4, 2014 15:58
Show Gist options
  • Save iammerrick/9977626 to your computer and use it in GitHub Desktop.
Save iammerrick/9977626 to your computer and use it in GitHub Desktop.
Custom Elements + ES6 + Namespacing
import ChildElement from './my-element/components/child-element'
// registerElement exists on any DOM element which provides namespacing
document.body.registerElement('my-element', Blink);
class Blink extends HTMLElement {
constructor() {
this.addEventListener('click', this.win);
// This is namespaced inside of my-element because that is where it is registered.
this.registerElement('child-element', ChildElement);
}
static get template() {
return `<span>This is neat: <child-element></child-element></span>`;
}
win() {
// Win callback
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment