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`:
https://github.com/whatwg/html/issues/10107#issuecomment-1937077298
Bug: 41483062,325598615
Change-Id: Ie3bac4ec297c0b85c40b45495e9c823dd47cb49e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5283935
Commit-Queue: Mason Freed <masonf@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Commit-Queue: Di Zhang <dizhangg@chromium.org>
Reviewed-by: Di Zhang <dizhangg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1262014}
diff --git a/shadow-dom/declarative/declarative-shadow-dom-repeats.html b/shadow-dom/declarative/declarative-shadow-dom-repeats.html
index 4f1b4c7..9cee41f 100644
--- a/shadow-dom/declarative/declarative-shadow-dom-repeats.html
+++ b/shadow-dom/declarative/declarative-shadow-dom-repeats.html
@@ -46,35 +46,48 @@
test((t) => {
assert_throws_dom("NotSupportedError",() => {
open1.attachShadow({mode: "closed"});
- },'Mismatched shadow root type should throw');
+ },'Mismatched shadow root mode should throw');
const initialShadow = open1.shadowRoot;
const shadow = open1.attachShadow({mode: "open"}); // Shouldn't throw
assert_equals(shadow,initialShadow,'Same shadow should be returned');
assert_equals(shadow.textContent,'','Shadow should be empty');
-},'Calling attachShadow() on declarative shadow root must match type');
+},'Calling attachShadow() on declarative shadow root must match mode');
</script>
<div id=open2>
- <template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable>
+ <template shadowrootmode=open shadowrootdelegatesfocus shadowrootclonable serializable>
Open, delegates focus (not the default), clonable (not the default)
- named slot assignment (the default)
+ serializable (not the default), named slot assignment (the default)
</template>
</div>
<script>
test((t) => {
+ t.add_cleanup(() => open2.remove());
+ assert_true(!!open2.shadowRoot);
+ // Changing the mode should throw.
assert_throws_dom("NotSupportedError",() => {
- open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true});
+ open2.attachShadow({mode: "closed"});
},'Mismatched shadow root mode should throw');
+ assert_throws_dom("NotSupportedError",() => {
+ open2.attachShadow({mode: "closed", delegatesFocus: true, slotAssignment: "named", clonable: true, serializable: true});
+ },'Mismatched shadow root mode should throw (explicit args)');
+ // Changing other things should not throw, and should not change the shadow root's settings
const initialShadow = open2.shadowRoot;
- const shadow = open2.attachShadow({mode: "open", delegatesFocus: true, slotAssignment: "named", clonable: true}); // Shouldn't throw
- assert_equals(shadow,initialShadow,'Same shadow should be returned');
- assert_equals(shadow.textContent,'','Shadow should be empty');
-
+ assert_equals(initialShadow.delegatesFocus,true);
+ assert_equals(initialShadow.slotAssignment,"named");
+ assert_true(initialShadow.clonable);
+ assert_true(initialShadow.serializable);
+ let newShadow = open2.attachShadow({mode: "open", delegatesFocus: false, slotAssignment: "manual", clonable: false, serializable: false});
+ assert_equals(newShadow,initialShadow,'Same shadow should be returned');
+ assert_equals(newShadow.textContent,'','Shadow should be empty');
+ assert_equals(newShadow.delegatesFocus,true);
+ assert_equals(newShadow.slotAssignment,"named");
+ assert_true(newShadow.clonable);
+ assert_true(newShadow.serializable);
assert_throws_dom("NotSupportedError",() => {
open2.attachShadow({mode: "open"});
},'Invoking attachShadow() on a non-declarative shadow root should throw');
-
},'Calling attachShadow() on declarative shadow root must match all parameters');
</script>