Created
April 4, 2014 15:58
-
-
Save iammerrick/9977626 to your computer and use it in GitHub Desktop.
Custom Elements + ES6 + Namespacing
This file contains 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 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