-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There have been a few changes to declarative shadow DOM #32289
Comments
Thanks a lot for reporting. Tagging @pepelsbey who has better context on these docs lately |
Are you sure that
I can only confirm this behavior in Chrome:
Both Firefox and Safari don’t throw any exceptions when I try to attach a shadow with a mode different from the one that is declared via the <p>outer</p>
<div>
<template shadowrootmode="open">
<p>inner</p>
</template>
</div>
<script>
const div = document.querySelector('div');
const shadow = div.attachShadow({ mode: 'closed' });
const span = document.createElement('span');
span.textContent = 'text';
shadow.appendChild(span);
</script> |
Yes, it's a bit odd, since in the normal course of usage you'd never do
Right, I don't think they've shipped the new behavior yet. I shipped it in Chrome v122, pretty recently. I'm hoping/guessing Gecko and WebKit aren't far behind. |
@pepelsbey FYI, the first two points have been addressed this week in MDN as part of the FF releases.
As stated above the I have said that so that it is clear the properties are pointless. |
@pepelsbey @mfreed7 As per the note above, only the last point remains
@mfreed7 you noted that in
Looking round I find whatwg/dom#1235 (comment) So would I be correct that the spec has been updated as stated?:
FYI, I'm doing this for #32731 - might end up having more questions there. |
That's correct. It's a change, but it's been shipped in Chrome and we haven't seen issues. This is fairly corner case - most people don't include more than one declarative shadow root
Right. If the parameters don't match, an exception will be thrown now. Again, shipped in Chrome and we haven't seen compat issues.
That's also right. The point of this behavior is for web components that are implemented without knowledge of declarative shadow roots that might be present due to server side rendering, for example. To avoid breaking those components, if they call |
Thanks @mfreed7 - I have captured this in #33650 - would appreciate your sanity check of that. Note that according to the spec you can Anyway, once that goes in, this issue can close. |
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow
What specific section or headline is this issue about?
Declarative shadow DOM
What information was incorrect, unhelpful, or incomplete?
There have been some recent spec changes to declarative shadow DOM:
<template>
element now has ashadowrootclonable
attribute, to control theclonable
attribute of the shadow root for declarative shadow DOM. That should be mentioned here https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement.clonable
is no longertrue
for declarative shadow roots. The default is alwaysfalse
. See https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow.attachShadow()
with an existing declarative shadow root worked previously, but will now throw an exception if themode
doesn't match the existing root'smode
. I don't believe this is documented anywhere, but this page says anInvalidStateException
will be thrown if there's already a shadow root, which isn't exactly true.Thanks!
What did you expect to see?
See above.
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
No response
The text was updated successfully, but these errors were encountered: