blob: ab7b2af05aa1b7aee94e473aca98139ccaec1fbd (
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
|
<!DOCTYPE html>
<meta charset="utf-8" >
<meta name="author" title="Di Zhang" href="mailto:dizhangg@chromium.org">
<meta name="assert" content="Modify slot fallback contents, when dynamically created.">
<title>Shadow DOM: Slots and fallback contents</title>
<link rel="match" href="slot-fallback-content-003-ref.html">
<p>Test passes if there are two lines of text "SLOT1", "A" below.</p>
<div id="host1"><slot id="slot1">SLOT1</slot></div>
<p>Test passes if there is one line of text "C" below.</p>
<div id="host2"><slot id="slot2">
<div id="B">FAIL</div>
<div id="C">C</div>
</slot></div>
<p>Test passes if empty.</p>
<div id="host3">
<slot id="slot3">
<div id="D">FAIL</div>
</slot>
</div>
<script>
// Content added to existing fallback content will be rendered
const shadowRoot1 = host1.attachShadow({ mode: "open" });
shadowRoot1.appendChild(slot1);
const A = document.createElement('div');
A.innerText = 'A';
shadowRoot1.getElementById('slot1').appendChild(A);
// Remove some content from existing slot fallback will render the leftover fallback
const shadowRoot2 = host2.attachShadow({ mode: "open" });
shadowRoot2.appendChild(slot2);
const B = shadowRoot2.getElementById('B');
B.remove();
// // Remove all content from existing slot fallback will render no fallback
const shadowRoot3 = host3.attachShadow({ mode: "open" });
shadowRoot3.appendChild(slot3);
const D = shadowRoot3.getElementById('D');
D.remove();
</script>
|