Skip to content

Commit 722d4a1

Browse files
mfreed7chromium-wpt-export-bot
authored andcommittedFeb 13, 2024
Only check for matching mode in attachShadow
Per the new-new consensus, attachShadow will only verify that the existing declarative shadow root's `mode` matches the newly requested `mode`: whatwg/html#10107 (comment) Bug: 41483062 Change-Id: Ie3bac4ec297c0b85c40b45495e9c823dd47cb49e
1 parent 2380ac0 commit 722d4a1

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed
 

‎shadow-dom/declarative/declarative-shadow-dom-repeats.html ‎shadow-dom/declarative/declarative-shadow-dom-repeats.tentative.html

+30-20
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,43 @@
4646
assert_equals(shadow,initialShadow,'Same shadow should be returned');
4747
assert_equals(shadow.textContent,'','Shadow should be empty');
4848
},'Calling attachShadow() on declarative shadow root must match type');
49-
</script>
5049

51-
<div id=open2>
52-
<template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable>
53-
Open, delegates focus (not the default), clonable (not the default)
54-
named slot assignment (the default)
55-
</template>
56-
</div>
50+
function getDeclarativeHost(t) {
51+
const div = document.createElement('div');
52+
div.setHTMLUnsafe(`
53+
<template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable serializable>
54+
Open, delegates focus (not the default), clonable (not the default)
55+
serializable (not the default), named slot assignment (the default)
56+
</template>
57+
`);
58+
t.add_cleanup(() => div.remove());
59+
document.body.appendChild(div);
60+
return div;
61+
}
5762

58-
<script>
5963
test((t) => {
64+
// Changing the type should throw.
65+
let host = getDeclarativeHost(t);
6066
assert_throws_dom("NotSupportedError",() => {
61-
open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true});
67+
host.attachShadow({mode: "closed"});
6268
},'Mismatched shadow root type should throw');
6369
assert_throws_dom("NotSupportedError",() => {
64-
open2.attachShadow({mode: "open", delegatesFocus: false, slotAssignment: "named", clonable: true});
65-
},'Mismatched shadow root delegatesFocus should throw');
66-
assert_throws_dom("NotSupportedError",() => {
67-
open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "manual", clonable: true});
68-
},'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');
70+
host.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true, serializable: true});
71+
},'Mismatched shadow root type should throw (explicit args)');
7272

73-
const initialShadow = open2.shadowRoot;
74-
const shadow = open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "named", clonable: true}); // Shouldn't throw
75-
assert_equals(shadow,initialShadow,'Same shadow should be returned');
73+
// Changing other things should not throw, and should not change the shadow root's settings
74+
host = getDeclarativeHost(t);
75+
assert_equals(host.delegatesFocus,true);
76+
assert_equals(host.slotAssignment,"named");
77+
assert_true(host.clonable);
78+
assert_true(host.serializable);
79+
const initialShadow = host.shadowRoot;
80+
let newShadow = host.attachShadow({mode: "open", delegatesFocus: false, slotAssignment: "manual", clonable: false, serializable: false});
81+
assert_equals(newShadow,initialShadow,'Same shadow should be returned');
7682
assert_equals(shadow.textContent,'','Shadow should be empty');
83+
assert_equals(host.delegatesFocus,true);
84+
assert_equals(host.slotAssignment,"named");
85+
assert_true(host.clonable);
86+
assert_true(host.serializable);
7787
},'Calling attachShadow() on declarative shadow root must match all parameters');
7888
</script>

0 commit comments

Comments
 (0)