Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-cascade/scope-slotted.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>@scope - slotted elements</title>
<link rel="match" href="scope-slotted-ref.html">
<meta name="assert" content="@scope rules match elements slotted into shadow DOM">
<style>
h1 { color: green; }
@scope (.test-scope) {
h1 { color: purple; }
}
</style>
<div class="test-scope">
<x-card>
<h1 slot="heading">Slotted H1</h1>
</x-card>
<h1>Unslotted H1</h1>
</div>
<script>
customElements.define('x-card', class extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' }).innerHTML = '<slot name="heading"></slot><slot></slot>';
}
});
</script>