Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 19 additions & 26 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2899,15 +2899,11 @@ before a <var>child</var>, with an optional <i>suppress observers flag</i>, run
<a for=iteration>continue</a>.

<li>
<p>If <var>inclusiveDescendant</var> is an <a for=/>element</a>:
<p>If <var>inclusiveDescendant</var> is an <a for=/>element</a> and
<var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> is non-null:

<ol>
<li><p>If <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> is
null, then set <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> to
the result of <a for=/>looking up a custom element registry</a> given
<var>inclusiveDescendant</var>'s <a for=tree>parent</a>.

<li><p>Otherwise, if <var>inclusiveDescendant</var>'s
<li><p>If <var>inclusiveDescendant</var>'s
<a for=Element>custom element registry</a>'s <a for=CustomElementRegistry>is scoped</a> is
true, <a for=set>append</a> <var>inclusiveDescendant</var>'s <a for=Node>node document</a> to
<var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a>'s
Expand All @@ -2930,14 +2926,7 @@ before a <var>child</var>, with an optional <i>suppress observers flag</i>, run
<p>Otherwise, 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 and <var>inclusiveDescendant</var>'s
<a for=ShadowRoot>keep custom element registry null</a> is false, then set
<var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a> to the result
of <a for=/>looking up a custom element registry</a> given <var>inclusiveDescendant</var>'s
<a for=DocumentFragment>host</a>.

<li><p>Otherwise, if <var>inclusiveDescendant</var>'s
<li><p>If <var>inclusiveDescendant</var>'s
<a for=ShadowRoot>custom element registry</a> is non-null and
<var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a>'s
<a for=CustomElementRegistry>is scoped</a> is true, <a for=set>append</a>
Expand Down Expand Up @@ -6018,11 +6007,16 @@ these steps:
<ol>
<li><p>Set <var>inclusiveDescendant</var>'s <a for=Node>node document</a> to <var>document</var>.

<li><p>If <var>inclusiveDescendant</var> is a <a for=/>shadow root</a> and
<var>inclusiveDescendant</var>'s <a for=ShadowRoot>custom element registry</a>
<a>is a global custom element registry</a>, 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>:

<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>.
Comment on lines +6010 to +6018
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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>.

Copy link
Member

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?

Copy link
Author

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:

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.

Copy link
Member

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?

Copy link
Author

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DSD is only created during document parsing

It can be created with setHTMLUnsafe.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annevk Is this the reason or related to it that you're suggesting we still need the check? To distinguish these cases?

<template id="template">
  <div id="host1">
    <template shadowrootmode="open"><x-foo></x-foo></template>
  </div>
  <div id="host2">
    <template shadowrootmode="open" shadowrootcustomelementregistry><x-foo></x-foo></template>
  </div>
</template>
customElements.define('x-foo', class extends HTMLElement {});
document.body.append(template.content.cloneNode(true));
console.assert(host1.shadowRoot.querySelector('x-foo:defined') === true);
console.assert(host2.shadowRoot.querySelector('x-foo:defined') === false);

</ol>

<li>
<p>Otherwise, if <var>inclusiveDescendant</var> is an <a for=/>element</a>:
Expand All @@ -6032,9 +6026,10 @@ these steps:
<var>inclusiveDescendant</var>'s <a for=Element>attribute list</a> to <var>document</var>.

<li><p>If <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a>
<a>is a global custom element registry</a>, then set <var>inclusiveDescendant</var>'s
<a for=Element>custom element registry</a> to <var>document</var>'s
<a>effective global custom element registry</a>.
is null or <var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a>'s
<a for=CustomElementRegistry>is scoped</a> is false, then set
<var>inclusiveDescendant</var>'s <a for=Element>custom element registry</a> to
<var>document</var>'s <a>effective global custom element registry</a>.
</ol>
</ol>

Expand Down Expand Up @@ -6503,9 +6498,6 @@ It is initially set to false.</p>
<p><a for=/>Shadow roots</a> have an associated <dfn for=ShadowRoot>custom element registry</dfn>
(null or a {{CustomElementRegistry}} object). It is initially null.</p>

<p><a for=/>Shadow roots</a> have an associated
<dfn for=ShadowRoot>keep custom element registry null</dfn> (a boolean). It is initially false.

<p class=note>This can only ever be true in combination with declarative shadow roots. And it only
matters for as long as the <a for=/>shadow root</a>'s <a for=ShadowRoot>custom element registry</a>
is null.
Expand Down Expand Up @@ -11047,6 +11039,7 @@ James Graham,
James Greene,
James M Snell,
James Robinson,
Jayson Chen,
Jeffrey Yasskin,
Jens Lindström,
Jeremy Davis<!-- jeremydavis519; GitHub -->,
Expand Down