-
Notifications
You must be signed in to change notification settings - Fork 318
Set registry on null registry element on adopt instead of on insert #1423
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches my understanding of the first set of changes proposed in #1413 (comment) and agreed to at TPAC. Good job!
One minor point: it seems like since insert 7.1 does adopt, perhaps insert 7.7.3.1 and 7.7.4.1 are no longer needed?
|
@rniwa One thing I'd like to clarify from your PR: One of the test files added is phrased as "append does not upgrade". However, is it correct that we still want to run upgrade during append/insertion steps? It is possible that a null registry element gets a registry when it's appended cross document (which involves adopt steps). In that case we'll want to run an upgrade on the element right? Want to make sure I got the correct understanding here. |
So regular append should upgrade elements that have a non-null custom element registry. An element with null registry should retain its null registry state and not get upgraded upon insertion.
Yes, in the cross-document append case, we'd first adopt the element to the destination document at which point the null registry will be replaced with the global registry of the destination document. |
…ing null to createEleent and attachShadow per - whatwg/dom#1424 - whatwg/dom#1423 Also update the existing tests to account for the behavior differences.`
…ing null to createEleent and attachShadow per - whatwg/dom#1424 - whatwg/dom#1423 Also update the existing tests to account for the behavior differences.`
@sorvell My understanding is that the scoped document set is used for searching for upgrade candidates in the case of new definition added, so we'll need to keep those two steps around. |
…ing null to createEleent and attachShadow per (#56108) - whatwg/dom#1424 - whatwg/dom#1423 Also update the existing tests to account for the behavior differences.`
| <li> | ||
| <p>If <var>inclusiveDescendant</var> is a <a for=/>shadow root</a>: | ||
|
|
||
| <ol> | ||
| <li><p>if <var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a> | ||
| is null or <var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a>'s | ||
| <a for=CustomElementRegistry>is scoped</a> is false, then set | ||
| <var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a> to | ||
| <var>document</var>'s <a>effective global custom element registry</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <li> | |
| <p>If <var>inclusiveDescendant</var> is a <a for=/>shadow root</a>: | |
| <ol> | |
| <li><p>if <var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a> | |
| is null or <var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a>'s | |
| <a for=CustomElementRegistry>is scoped</a> is false, then set | |
| <var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a> to | |
| <var>document</var>'s <a>effective global custom element registry</a>. | |
| <li><p>If <var>inclusiveDescendant</var> is a <a for=/>shadow root</a> and either | |
| <var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a> is null or | |
| <var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a>'s | |
| <a for=CustomElementRegistry>is scoped</a> is false, then set <var>inclusiveDescendant</var>'s | |
| <a for=ShadowRoot>custom element registry</a> to <var>document</var>'s | |
| <a>effective global custom element registry</a>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I think this is incorrect and we still need "keep custom element registry null" here. Have you looked at how the HTML Standard sets "keep custom element registry null"? How is the shadowrootcustomelementregistry content attribute supported in this new world?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In HTML spec where we define the parsing logic for "A start tag whose tag name is "template", we have two repetitive lines describing how shadowrootcustomelementregistry attribute is used:
- If templateStartTag has a shadowrootcustomelementregistry attribute, then set registry to null.
- If templateStartTag has a shadowrootcustomelementregistry attribute, then set shadow's keep custom element registry null to true.
I think we can remove that second line and completely remove the usage of "keep custom element registry null" and we can simply rely on setting the shadowroot's registry to null to support shadowrootcustomelementregistry content attribute behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we distinguish the case of a shadow root from a null document registry without the attribute from one with the attribute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to have a DSD with null registry due to shadowrootcustomelementregistry in a null registry document though? Assuming my understanding is correct on "DSD is only created during document parsing and we're not able to get a null registry document during document parsing (has to through JS code like document.implementation.createHTMLDocument();)"
In that case, we can safely assign a registry to null registry shadow root on adopt and remove the need of "keep custom element registry" as we don't assign registry on append regardless.
In order to support scenarios for elements with a null custom element registry without shadow DOM, we decided to modify the behavior when it comes to setting registry on null registry element. By setting the registry on adopt instead of on insert allows us to have null registry element in light DOM while being backwards-compatible.
Fixes #1413 partially. There are two more spec changes expected to add element attribute and allow null registry option during element creation and shadow attachment as mentioned in #1413 (comment)
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff