Created
May 20, 2020 00:19
-
-
Save Danetag/9c39d314bdb8428d96a1200940739eba to your computer and use it in GitHub Desktop.
This file contains hidden or 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 definition --> | |
<template id="fancy-element-template"> | |
<style> | |
... | |
</style> | |
<div class="container"> | |
<p>Some fancy markup goes here...</p> | |
</div> | |
</template> | |
<script> | |
customElements.define('fancy-element', class extends HTMLElement { | |
constructor() { | |
super(); | |
const shadowRoot = this.attachShadow({mode: 'open'}); | |
const t = document.querySelector('#fancy-element-template'); | |
const instance = t.content.cloneNode(true); | |
shadowRoot.appendChild(instance); | |
} | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment