Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<div id="nameTag">Bob</div>
<template id="nameTagTemplate">
<style>
.outer {
border: 2px solid brown;
background: red;
}
.name {
color: black;
}
</style>
<div class="outer">
<div class="name">
Bob
</div>
</div>
</template>
var shadow = document.querySelector('#nameTag').createShadowRoot();
var template = document.querySelector('#nameTagTemplate');
var clone = document.importNode(template.content, true);
shadow.appendChild(clone);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment