Created
May 28, 2018 14:09
-
-
Save kyuwoo-choi/4c37f7f2a30d4b0f4a40ae7ab311c55f 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
<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> |
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
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