|
49 | 49 | </script>
|
50 | 50 |
|
51 | 51 | <div id=open2>
|
52 |
| - <template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable> |
| 52 | + <template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable serializable> |
53 | 53 | Open, delegates focus (not the default), clonable (not the default)
|
54 |
| - named slot assignment (the default) |
| 54 | + serializable (not the default), named slot assignment (the default) |
55 | 55 | </template>
|
56 | 56 | </div>
|
57 | 57 |
|
58 | 58 | <script>
|
59 | 59 | test((t) => {
|
| 60 | + // These should match the declarative shadow root above. |
| 61 | + const originalProps = {mode: "open", delegatesFocus: true, slotAssignment: "named", clonable: true, serializable: true}; |
| 62 | + |
| 63 | + // Changing these should throw. |
60 | 64 | assert_throws_dom("NotSupportedError",() => {
|
61 |
| - open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true}); |
| 65 | + open2.attachShadow({...originalProps, mode: "closed"}); |
62 | 66 | },'Mismatched shadow root type should throw');
|
63 | 67 | assert_throws_dom("NotSupportedError",() => {
|
64 |
| - open2.attachShadow({mode: "open", delegatesFocus: false, slotAssignment: "named", clonable: true}); |
| 68 | + open2.attachShadow({...originalProps, delegatesFocus: false}); |
65 | 69 | },'Mismatched shadow root delegatesFocus should throw');
|
66 | 70 | assert_throws_dom("NotSupportedError",() => {
|
67 |
| - open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "manual", clonable: true}); |
| 71 | + open2.attachShadow({...originalProps, slotAssignment: "manual"}); |
68 | 72 | },'Mismatched shadow root slotAssignment should throw');
|
69 |
| - assert_throws_dom("NotSupportedError",() => { |
70 |
| - open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "named", clonable: false}); |
71 |
| - },'Mismatched shadow root clonable should throw'); |
72 | 73 |
|
| 74 | + // Boolean arguments just update the shadow root, and return the same root. |
73 | 75 | const initialShadow = open2.shadowRoot;
|
74 |
| - const shadow = open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "named", clonable: true}); // Shouldn't throw |
| 76 | + assert_true(open2.shadowRoot.clonable); |
| 77 | + assert_true(open2.shadowRoot.serializable); |
| 78 | + const shadow = open2.attachShadow({...originalProps, clonable: false, serializable: false}); // Shouldn't throw |
75 | 79 | assert_equals(shadow,initialShadow,'Same shadow should be returned');
|
76 | 80 | assert_equals(shadow.textContent,'','Shadow should be empty');
|
| 81 | + assert_false(open2.shadowRoot.clonable,'clonable flag should be updated'); |
| 82 | + assert_false(open2.shadowRoot.serializable,'serializable flag should be updated'); |
77 | 83 | },'Calling attachShadow() on declarative shadow root must match all parameters');
|
78 | 84 | </script>
|
0 commit comments