<template id="content">
	<h1>createShadowDomByJs</h1>
</template>

<div id="shadow-dom-host"></div>
#shadow-dom-host{

}
View Compiled
// Polyfill support
HTMLElement.prototype.createShadowRoot = 
  HTMLElement.prototype.createShadowRoot ||
  HTMLElement.prototype.webkitCreateShadowRoot ||
  function() {};

var tmpl = document.querySelector('#content');
var host = document.querySelector('#shadow-dom-host');
// Create a Shadow Root
var root = host.createShadowRoot();
// Append elements to the Shadow Root
root.appendChild(document.importNode(tmpl.content, true));
Rerun