Last active
August 29, 2015 14:09
-
-
Save shaunwallace/c38399d9807d4ea85431 to your computer and use it in GitHub Desktop.
Simple Shadow DOM example with <content> and <template>
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
<section class="info-card"> | |
John Smith | |
</section> | |
<template class="info-car-tmpl"> | |
<h1>Hello, <content></content>!</h1> | |
</template> | |
<script> | |
// define our shadow host | |
var host = document.querySelector('.info-card'); | |
// creat out shadow root | |
var root = host.createShadowRoot(); | |
// grab our template | |
var template = document.querySelector('.info-card-tmpl'); | |
// insert our template into our shadow root | |
root.appendChild( document.importNode( template.content, true ) ); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment