Created
October 16, 2018 06:57
-
-
Save dzenzes/a7ab771597000cababb137fe34a03912 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
let tmpl = document.createElement("template"); // (1) | |
tmpl.innerHTML = ` | |
<ul id="webcomponents"> | |
<li>HTML Template</li> | |
<li>HTML Import</li> | |
<li>Shadow DOM</li> | |
<li>Custom Elements</li> | |
</ul>`; | |
class WebComponents extends HTMLElement { | |
constructor() { | |
super(); // always call super() first in the ctor. | |
let shadowRoot = this.attachShadow({ | |
//(2) | |
mode: "open" | |
}); | |
shadowRoot.appendChild(tmpl.content.cloneNode(true)); // (3) | |
} | |
} | |
window.customElements.define("web-components", WebComponents); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment