Skip to content

Instantly share code, notes, and snippets.

@motss
Created September 3, 2016 15:33
Show Gist options
  • Save motss/ebf6b8e8376296080a1556853eeeb3e4 to your computer and use it in GitHub Desktop.
Save motss/ebf6b8e8376296080a1556853eeeb3e4 to your computer and use it in GitHub Desktop.
Custom Element v0 + Shadow DOM v0 demo
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