summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/shadow-dom/slot-fallback-content-004.html
blob: b7ca7144e4f76349b27d156f8a76a97b7f650ddc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!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>