Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset="utf-8" >
<meta name="author" title="Di Zhang" href="mailto:dizhangg@chromium.org">
<meta name="assert" content="Remove assigned light nodes of a slot, when dynamically created.">
<title>Shadow DOM: Slots and fallback contents</title>
<link rel="match" href="slot-fallback-content-004-ref.html">
<p>Test passes if there is one line of text "SLOT1" below.</p>
<div id="host1">
<slot id="slot1" name="slot1">SLOT1</slot>
<div id="A" slot="slot1">FAIL</div>
</div>
<p>Test passes if empty.</p>
<div id="host2">
<slot id="slot2" name="slot2"></slot>
<div id="B" slot="slot2">FAIL</div>
</div>
<p>Test passes if there is one line of text "SLOT3" below.</p>
<div id="host3">
<slot id="slot3" name="slot3">SLOT3</slot>
<div id="C" slot="slot3">FAIL</div>
</div>
<p>Test passes if there is one line of text "SLOT4" below.</p>
<div id="host4">
<slot id="slot4" name="slot4">SLOT4</slot>
<div id="D" slot="slot4">FAIL</div>
</div>
<script>
// Remove a slot's assigned node should show fallback content
const shadowRoot1 = host1.attachShadow({ mode: "open" });
shadowRoot1.appendChild(slot1);
A.remove();
// Remove a slot's assigned node with no fallback should show nothing
const shadowRoot2 = host2.attachShadow({ mode: "open" });
shadowRoot2.appendChild(slot2);
B.remove();
// Remove the slot attribute to an assigned node should show fallback content
const shadowRoot3 = host3.attachShadow({ mode: "open" });
shadowRoot3.appendChild(slot3);
C.removeAttribute('slot');
// Change the slot attribute to an assigned node to an unknown slot
// should show fallback content
const shadowRoot4 = host4.attachShadow({ mode: "open" });
shadowRoot4.appendChild(slot4);
D.setAttribute('slot', 'invalid');
</script>