Skip to content

Commit a092215

Browse files
mfreed7chromium-wpt-export-bot
authored andcommittedFeb 17, 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,325598615 Change-Id: Ie3bac4ec297c0b85c40b45495e9c823dd47cb49e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5283935 Commit-Queue: Mason Freed <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Di Zhang <[email protected]> Reviewed-by: Di Zhang <[email protected]> Cr-Commit-Position: refs/heads/main@{#1262014}
1 parent a415844 commit a092215

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed
 

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

+23-10
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,48 @@
4646
test((t) => {
4747
assert_throws_dom("NotSupportedError",() => {
4848
open1.attachShadow({mode: "closed"});
49-
},'Mismatched shadow root type should throw');
49+
},'Mismatched shadow root mode should throw');
5050
const initialShadow = open1.shadowRoot;
5151
const shadow = open1.attachShadow({mode: "open"}); // Shouldn't throw
5252
assert_equals(shadow,initialShadow,'Same shadow should be returned');
5353
assert_equals(shadow.textContent,'','Shadow should be empty');
54-
},'Calling attachShadow() on declarative shadow root must match type');
54+
},'Calling attachShadow() on declarative shadow root must match mode');
5555
</script>
5656

5757
<div id=open2>
58-
<template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable>
58+
<template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable serializable>
5959
Open, delegates focus (not the default), clonable (not the default)
60-
named slot assignment (the default)
60+
serializable (not the default), named slot assignment (the default)
6161
</template>
6262
</div>
6363

6464
<script>
6565
test((t) => {
66+
t.add_cleanup(() => open2.remove());
67+
assert_true(!!open2.shadowRoot);
68+
// Changing the mode should throw.
6669
assert_throws_dom("NotSupportedError",() => {
67-
open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true});
70+
open2.attachShadow({mode: "closed"});
6871
},'Mismatched shadow root mode should throw');
72+
assert_throws_dom("NotSupportedError",() => {
73+
open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true, serializable: true});
74+
},'Mismatched shadow root mode should throw (explicit args)');
6975

76+
// Changing other things should not throw, and should not change the shadow root's settings
7077
const initialShadow = open2.shadowRoot;
71-
const shadow = open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "named", clonable: true}); // Shouldn't throw
72-
assert_equals(shadow,initialShadow,'Same shadow should be returned');
73-
assert_equals(shadow.textContent,'','Shadow should be empty');
74-
78+
assert_equals(initialShadow.delegatesFocus,true);
79+
assert_equals(initialShadow.slotAssignment,"named");
80+
assert_true(initialShadow.clonable);
81+
assert_true(initialShadow.serializable);
82+
let newShadow = open2.attachShadow({mode: "open", delegatesFocus: false, slotAssignment: "manual", clonable: false, serializable: false});
83+
assert_equals(newShadow,initialShadow,'Same shadow should be returned');
84+
assert_equals(newShadow.textContent,'','Shadow should be empty');
85+
assert_equals(newShadow.delegatesFocus,true);
86+
assert_equals(newShadow.slotAssignment,"named");
87+
assert_true(newShadow.clonable);
88+
assert_true(newShadow.serializable);
7589
assert_throws_dom("NotSupportedError",() => {
7690
open2.attachShadow({mode: "open"});
7791
},'Invoking attachShadow() on a non-declarative shadow root should throw');
78-
7992
},'Calling attachShadow() on declarative shadow root must match all parameters');
8093
</script>

0 commit comments

Comments
 (0)