Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<body>
<div id="slot-test">
<!-- Light DOM -->
<span slot="title">Hello</span>
<span slot="desc">world</span>
</div>
</body>
<script>
// Shadow DOM
document.querySelector('#slot-test')
.attachShadow({mode: 'open'})
.innerHTML = `
<h1>
<slot name="title"></slot>
</h1>
<p>
<slot name="desc"></slot>
</p>
`;
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment