Last active
October 10, 2017 00:47
-
-
Save emolr/ff11b32994dbe34cfca8f99f7d457311 to your computer and use it in GitHub Desktop.
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
class MyElement extends HTMLElement { | |
constructor() { | |
super(); | |
// We create a shadowDOM | |
this.attachShadow({mode: 'open'}); | |
// Then we inject a html template into the created ShadowDOM | |
this.shadowRoot.innerHTML = ` | |
Hello, I'm a web component | |
`; | |
} | |
} | |
// Register the web component | |
window.customElements.define('my-element', MyElement); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment