Skip to content

Instantly share code, notes, and snippets.

@kyuwoo-choi
Created May 28, 2018 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyuwoo-choi/4c37f7f2a30d4b0f4a40ae7ab311c55f to your computer and use it in GitHub Desktop.
Save kyuwoo-choi/4c37f7f2a30d4b0f4a40ae7ab311c55f to your computer and use it in GitHub Desktop.
<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