Skip to content

Instantly share code, notes, and snippets.

@sz332
Last active February 21, 2018 14:44
Show Gist options
  • Save sz332/c2054b98b7de22b896e2da9e669737d8 to your computer and use it in GitHub Desktop.
Save sz332/c2054b98b7de22b896e2da9e669737d8 to your computer and use it in GitHub Desktop.
Shadow dom
<html>
<body>
<div id="wrapper">
</div>
<div>This has normal color.</div>
<script>
let shadowRoot = document.getElementById("wrapper").attachShadow({
mode: 'open'
});
shadowRoot.innerHTML = '<h1>This is some header</h1><div>This text is red.</div>';
shadowRoot.innerHTML += '<style>div { color: red; }</style>';
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment