Created
October 16, 2018 06:48
-
-
Save dzenzes/d7b204d292d61f65573f920a0aa6c2ff to your computer and use it in GitHub Desktop.
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
if (document.head.createShadowRoot || document.head.attachShadow) { | |
const shadow = document.querySelector("#webcomponents").attachShadow({ | |
// (1) | |
mode: "open"(2) | |
}); | |
shadow.innerHTML = "<p>HTML Template</p>"; // (2) | |
shadow.innerHTML += "<p>HTML Import</p>"; | |
shadow.innerHTML += "<p>Shadow DOM</p>"; | |
shadow.innerHTML += "<p>Custom Elements</p>"; | |
shadow.innerHTML += ` (4) | |
<style> | |
p{ | |
color: red; | |
} | |
</style> | |
`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment