Last active
February 21, 2018 14:44
-
-
Save sz332/c2054b98b7de22b896e2da9e669737d8 to your computer and use it in GitHub Desktop.
Shadow dom
This file contains 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
<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