Created
May 8, 2014 07:02
-
-
Save TakayoshiKochi/d025e9b3728d0ff39fb7 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="yosin"> | |
<span class=name>Yoshifumi</span> | |
<span class=company>Google</span> | |
</div> | |
<div id="kochi"> | |
<span class=name>Takayoshi</span> | |
<span class=company>Google</span> | |
</div> | |
<template id=namecard> | |
<div class="card"> | |
<style> | |
div { | |
border: 1px solid #408040; | |
border-radius: 3px; | |
padding: 5px; | |
margin-bottom: 5px; | |
} | |
</style> | |
<span>Name:</span> | |
<content select=".name"></content><br> | |
<span>Company:</span> | |
<content select=".company"></content><br> | |
</div> | |
</template> | |
</body> | |
</html> |
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
var tmpl = document.querySelector('#namecard'); | |
var host = document.querySelector('#yosin'); | |
var root = host.createShadowRoot(); | |
root.appendChild(tmpl.content.cloneNode(true)); | |
var host2 = document.querySelector('#kochi'); | |
var root2 = host2.createShadowRoot(); | |
root2.appendChild(tmpl.content.cloneNode(true)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment