Last active
June 29, 2017 13:07
-
-
Save JCrestel/b4206e5b20b874a5793f9abcffe8f7c3 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
<template id="hello-world"> | |
<p>Hello World</p> | |
</template> | |
<script> | |
const templateHelloWorld = (document.currentScript || document._currentScript) | |
.ownerDocument.querySelector('#hello-world').content; | |
class HelloWorld extends HTMLElement { | |
connectedCallback() { | |
let shadowRoot = this.attachShadow({mode: 'open'}); | |
const content = document.importNode(templateHelloWorld, true); | |
this.shadowRoot.appendChild(content); | |
} | |
}; | |
window.customElements.define('hello-world', HelloWorld); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment