Skip to content

Instantly share code, notes, and snippets.

@shaunwallace
Last active August 29, 2015 14:09
Show Gist options
  • Save shaunwallace/c38399d9807d4ea85431 to your computer and use it in GitHub Desktop.
Save shaunwallace/c38399d9807d4ea85431 to your computer and use it in GitHub Desktop.
Simple Shadow DOM example with <content> and <template>
<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