Created
September 3, 2016 15:33
-
-
Save motss/ebf6b8e8376296080a1556853eeeb3e4 to your computer and use it in GitHub Desktop.
Custom Element v0 + Shadow DOM v0 demo
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
const a = document.createElement('div'); | |
document.body.appendChild(a); | |
const b = document.createElement('template'); | |
b.innerHTML = ` | |
<style> | |
:host { display: block; box-sizing: border-box; } | |
.container { background-color: var(--fancy-bg, red); | |
@media (min-width: 768px) { | |
:root { | |
--fancy-bg: blue; | |
} | |
} | |
</style> | |
<div class="container">Custom Element + Shadow DOM is awesome!</div> | |
`; | |
a.createShadowRoot().innerHTML = b.innerHTML; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment