Skip to content

Add Scoped Custom Element Registries#10869

Merged
annevk merged 6 commits intomainfrom
annevk/scoped-custom-element-registries
Apr 14, 2025
Merged

Add Scoped Custom Element Registries#10869
annevk merged 6 commits intomainfrom
annevk/scoped-custom-element-registries

Conversation

@annevk
Copy link
Copy Markdown
Member

@annevk annevk commented Dec 17, 2024

Please do not comment directly on this PR unless asked. It's a big change and we want to keep it manageable. Use #10854 instead.

DOM PR: whatwg/dom#1341.

Tests: web-platform-tests/wpt#50790

(See WHATWG Working Mode: Changes for more details.)


/custom-elements.html ( diff )
/document-lifecycle.html ( diff )
/document-sequences.html ( diff )
/dom.html ( diff )
/indices.html ( diff )
/infrastructure.html ( diff )
/parsing.html ( diff )
/scripting.html ( diff )

@annevk annevk marked this pull request as ready for review December 19, 2024 09:52
@annevk annevk added addition/proposal New features or enhancements topic: custom elements Relates to custom elements (as defined in DOM and HTML) topic: shadow Relates to shadow trees (as defined in DOM) labels Dec 19, 2024
annevk added a commit to whatwg/dom that referenced this pull request Dec 19, 2024
@annevk annevk force-pushed the annevk/scoped-custom-element-registries branch from ff4688a to 3ad2431 Compare December 19, 2024 10:07
annevk added a commit to whatwg/dom that referenced this pull request Feb 21, 2025
@annevk annevk force-pushed the annevk/scoped-custom-element-registries branch from 3ad2431 to 28bf12c Compare February 21, 2025 09:42
@annevk annevk force-pushed the annevk/scoped-custom-element-registries branch from f02797a to 98b171e Compare March 6, 2025 11:36
Copy link
Copy Markdown
Member

@foolip foolip left a comment

Choose a reason for hiding this comment

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

Editorial review pass up to the CustomElementRegistry IDL block.

source Outdated
<li><dfn data-x="concept-document-type" data-x-href="https://dom.spec.whatwg.org/#concept-document-type">document type</dfn> concept</li>
<li><dfn data-x="concept-DocumentFragment-host" data-x-href="https://dom.spec.whatwg.org/#concept-documentfragment-host">host</dfn> concept</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-root">shadow root</dfn> concept, and its <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus">delegates focus</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-available-to-element-internals">available to element internals</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-clonable">clonable</dfn>, and <dfn data-x="shadow-serializable" data-x-href="https://dom.spec.whatwg.org/#shadowroot-serializable">serializable</dfn>.</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-root">shadow root</dfn> concept, and its <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-delegates-focus">delegates focus</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-available-to-element-internals">available to element internals</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#shadowroot-clonable">clonable</dfn>, <dfn data-x="shadow-serializable" data-x-href="https://dom.spec.whatwg.org/#shadowroot-serializable">serializable</dfn>, <dfn data-x="shadow-root-custom-element-registry" data-x-href="https://whatpr.org/dom/1341.html#shadowroot-custom-element-registry">custom element registry</dfn>, and <dfn data-x-href="https://whatpr.org/dom/1341.html#shadowroot-keep-custom-element-registry-null">keep custom element registry null</dfn>.</li>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment to ensure that the URLs here change before this is merged.

<dfn data-x="concept-node-clone-parent" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-parent"><var>parent</var></dfn>, and the concept of
<dfn data-x="concept-node-clone-subtree" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-subtree"><var>subtree</var></dfn>,
<dfn data-x="concept-node-clone-parent" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-parent"><var>parent</var></dfn>, and
<dfn data-x="concept-node-clone-fallbackRegistry" data-x-href="https://dom.spec.whatwg.org/#clone-a-node-fallbackregistry"><var>fallbackRegistry</var></dfn>, and the concept of
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to double check that this URL is correct before landing.

attribute is a <span>boolean attribute</span>.</p>

<p>The <dfn element-attr for="template"><code
data-x="attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</code></dfn>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like this the longest attribute name so far, 31 characters. Maybe that's right, but have you thought about shorter names that you also think are OK?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's not ideal, but anything else would end up being inconsistent with the rest of the APIs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess it will be a fun piece of trivia to know if nothing else :)

Comment on lines +73428 to +73429
<p>To <dfn export>look up a custom element definition</dfn>, given null or a
<code>CustomElementRegistry</code> object <var>registry</var>, string-or-null
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This style seems more common for nullable objects:

Suggested change
<p>To <dfn export>look up a custom element definition</dfn>, given null or a
<code>CustomElementRegistry</code> object <var>registry</var>, string-or-null
<p>To <dfn export>look up a custom element definition</dfn>, given a
<code>CustomElementRegistry</code>-or-null <var>registry</var>, string-or-null

(I found NavigationFocusReset-or-null as the example follow.)

Copy link
Copy Markdown
Member

@foolip foolip left a comment

Choose a reason for hiding this comment

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

Editorial review done.

DOMString? <span data-x="dom-CustomElementRegistry-getName">getName</span>(CustomElementConstructor constructor);
<span data-x="idl-Promise">Promise</span>&lt;<span>CustomElementConstructor</span>&gt; <span data-x="dom-CustomElementRegistry-whenDefined">whenDefined</span>(DOMString name);
[<span>CEReactions</span>] undefined <span data-x="dom-CustomElementRegistry-upgrade">upgrade</span>(<span>Node</span> root);
<span data-x="dom-CustomElementRegistry">constructor</span>();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For other reviewers: It's hard to tell from the diff, so the new things here are the constructor and the initialize() method.

<p><span data-x="map remove">Remove</span> <var>registry</var>'s <span>relevant global
object</span>'s <span>active custom element constructor map</span>[<var>C</var>].</p>

<p class="note">This is a no-op if <var>C</var> immediately calls <code
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the case where super() isn't called covered by the tests?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

<li><p>If <var>current node</var>'s <span data-x="element-custom-element-registry">custom
element registry</span> is not <var>shadow</var>'s <span
data-x="shadow-root-custom-element-registry">custom element registry</span>, then append
"<code data-x=""> shadowrootcustomelementregistry=&quot;&quot;</code>".</p></li>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How does this fit together with the extension point, the reason that the IDL attribute reflects as a string and not a boolean? Shouldn't this preserve the attribute value for consistency / to avoid a change in behavior later?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It seems okay for serialization to change at that point.

@foolip
Copy link
Copy Markdown
Member

foolip commented Mar 19, 2025

OK, so the main thing I'm left wondering point is the reasoning behind shadowrootcustomelementregistry being a boolean attribute, but the shadowRootCustomElementRegistry IDL attribute reflecting as a string, per the comment in the spec.

If the value is the empty string, shadowRootCustomElementRegistry will be the empty string (falsy), but if it was reflected as a boolean it would be true. If the attribute isn't present, shadowRootCustomElementRegistry would also be the empty string, so how does one distinguish between the typical "attribute is present" and "attribute is absent" cases?

Maybe it makes sense if I learn more about how this might be extended in the future.

annevk added a commit to whatwg/dom that referenced this pull request Apr 7, 2025
@annevk annevk force-pushed the annevk/scoped-custom-element-registries branch from 8ef7c76 to 0bb0d3f Compare April 7, 2025 15:18
@annevk
Copy link
Copy Markdown
Member Author

annevk commented Apr 7, 2025

About shadowRootCustomElementRegistry: this is indeed kinda useless now, but the IDL attributes on template are not that useful to begin with. Making it reflect as a string will indeed allow for named scoped registries in the future. That you have to use hasAttribute() for now is not that big of a deal I think. I prefer that over making it reflect as a nullable string, even though that would be possible now that we made a tweak to reflection for ARIA.

</li>
</ol>

<p class="note">Once the custom element registry of a node is initialized to a
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for adding this note!

@foolip
Copy link
Copy Markdown
Member

foolip commented Apr 10, 2025

I've finished editorial review of this and whatwg/dom#1341 now, but I'd like @mfreed7 to weigh in to confirm implementer interest on behalf of Chromium.

@mfreed7
Copy link
Copy Markdown
Collaborator

mfreed7 commented Apr 10, 2025

I've finished editorial review of this and whatwg/dom#1341 now, but I'd like @mfreed7 to weigh in to confirm implementer interest on behalf of Chromium.

Thanks for the review! You can mark Chromium as interested.

annevk added a commit to web-platform-tests/wpt that referenced this pull request Apr 11, 2025
…gistry into registries

And rename away from .tentative for the Revamped Scoped Custom Element Registry tests as whatwg/html#10869 and whatwg/dom#1341 are about to land.
annevk added a commit to web-platform-tests/wpt that referenced this pull request Apr 14, 2025
…gistry into registries

And rename away from .tentative for the Revamped Scoped Custom Element Registry tests as whatwg/html#10869 and whatwg/dom#1341 are about to land.
@annevk annevk merged commit f2d8b88 into main Apr 14, 2025
2 checks passed
@annevk annevk deleted the annevk/scoped-custom-element-registries branch April 14, 2025 08:20
aarongable pushed a commit to chromium/chromium that referenced this pull request Apr 14, 2025
This implements the IDL definitions per the spec issue[1], however
all methods are basic stubs and do not execute any logic - the logic
will come with later patches.

I2P: https://groups.google.com/a/chromium.org/g/blink-dev/c/um-9YjJWyEQ/m/MhKN0L7FAgAJ

Spec PRs:

HTML: whatwg/html#10869
DOM: whatwg/dom#1341

[1]: whatwg/html#10854

Bug: 409577162
Change-Id: Ieee709ff15c13bdd0b1d7598e27031867062b592
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6443776
Reviewed-by: David Baron <dbaron@chromium.org>
Commit-Queue: Keith Cirkel <chromium@keithcirkel.co.uk>
Commit-Queue: David Baron <dbaron@chromium.org>
Auto-Submit: Keith Cirkel <chromium@keithcirkel.co.uk>
Cr-Commit-Position: refs/heads/main@{#1446589}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Apr 14, 2025
This implements the IDL definitions per the spec issue[1], however
all methods are basic stubs and do not execute any logic - the logic
will come with later patches.

I2P: https://groups.google.com/a/chromium.org/g/blink-dev/c/um-9YjJWyEQ/m/MhKN0L7FAgAJ

Spec PRs:

HTML: whatwg/html#10869
DOM: whatwg/dom#1341

[1]: whatwg/html#10854

Bug: 409577162
Change-Id: Ieee709ff15c13bdd0b1d7598e27031867062b592
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6443776
Reviewed-by: David Baron <dbaron@chromium.org>
Commit-Queue: Keith Cirkel <chromium@keithcirkel.co.uk>
Commit-Queue: David Baron <dbaron@chromium.org>
Auto-Submit: Keith Cirkel <chromium@keithcirkel.co.uk>
Cr-Commit-Position: refs/heads/main@{#1446589}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Apr 14, 2025
This implements the IDL definitions per the spec issue[1], however
all methods are basic stubs and do not execute any logic - the logic
will come with later patches.

I2P: https://groups.google.com/a/chromium.org/g/blink-dev/c/um-9YjJWyEQ/m/MhKN0L7FAgAJ

Spec PRs:

HTML: whatwg/html#10869
DOM: whatwg/dom#1341

[1]: whatwg/html#10854

Bug: 409577162
Change-Id: Ieee709ff15c13bdd0b1d7598e27031867062b592
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6443776
Reviewed-by: David Baron <dbaron@chromium.org>
Commit-Queue: Keith Cirkel <chromium@keithcirkel.co.uk>
Commit-Queue: David Baron <dbaron@chromium.org>
Auto-Submit: Keith Cirkel <chromium@keithcirkel.co.uk>
Cr-Commit-Position: refs/heads/main@{#1446589}
AtkinsSJ added a commit to AtkinsSJ/ladybird that referenced this pull request Apr 16, 2025
This corresponds to a couple of spec changes:

whatwg/html#10869
whatwg/dom#1341

The regressions are unfortunate and need looking into. The spec issues
I've reported mostly have fixes PRed too. Just going to wait for those.
AtkinsSJ added a commit to AtkinsSJ/ladybird that referenced this pull request Apr 22, 2025
This corresponds primarily to these spec changes, plus a few follow-up
spec fixes:

whatwg/dom#1341
whatwg/html#10869

Still looking into the test regressions. Those might be spec issues but
I'm currently assuming they're me issues. :^)
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Apr 23, 2025
…egistry and custom-element-registry into registries, a=testonly

Automatic update from web-platform-tests
custom-elements: merge revamped-scoped-registry and custom-element-registry into registries

And rename away from .tentative for the Revamped Scoped Custom Element Registry tests as whatwg/html#10869 and whatwg/dom#1341 are about to land.

--

wpt-commits: 7087b359a1e2e306db934e5ff11218bd871cb228
wpt-pr: 51953
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Apr 23, 2025
…ed registry, a=testonly

Automatic update from web-platform-tests
Scaffold out basic IDL for revamped scoped registry

This implements the IDL definitions per the spec issue[1], however
all methods are basic stubs and do not execute any logic - the logic
will come with later patches.

I2P: https://groups.google.com/a/chromium.org/g/blink-dev/c/um-9YjJWyEQ/m/MhKN0L7FAgAJ

Spec PRs:

HTML: whatwg/html#10869
DOM: whatwg/dom#1341

[1]: whatwg/html#10854

Bug: 409577162
Change-Id: Ieee709ff15c13bdd0b1d7598e27031867062b592
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6443776
Reviewed-by: David Baron <dbaron@chromium.org>
Commit-Queue: Keith Cirkel <chromium@keithcirkel.co.uk>
Commit-Queue: David Baron <dbaron@chromium.org>
Auto-Submit: Keith Cirkel <chromium@keithcirkel.co.uk>
Cr-Commit-Position: refs/heads/main@{#1446589}

--

wpt-commits: 9546e2007adb73a3545fb61a5e5c8f754c6587e4
wpt-pr: 51977
shtrom pushed a commit to mozilla-conduit/ff-test that referenced this pull request Apr 28, 2025
…egistry and custom-element-registry into registries, a=testonly

Automatic update from web-platform-tests
custom-elements: merge revamped-scoped-registry and custom-element-registry into registries

And rename away from .tentative for the Revamped Scoped Custom Element Registry tests as whatwg/html#10869 and whatwg/dom#1341 are about to land.

--

wpt-commits: 7087b359a1e2e306db934e5ff11218bd871cb228
wpt-pr: 51953
shtrom pushed a commit to mozilla-conduit/ff-test that referenced this pull request Apr 28, 2025
…ed registry, a=testonly

Automatic update from web-platform-tests
Scaffold out basic IDL for revamped scoped registry

This implements the IDL definitions per the spec issue[1], however
all methods are basic stubs and do not execute any logic - the logic
will come with later patches.

I2P: https://groups.google.com/a/chromium.org/g/blink-dev/c/um-9YjJWyEQ/m/MhKN0L7FAgAJ

Spec PRs:

HTML: whatwg/html#10869
DOM: whatwg/dom#1341

[1]: whatwg/html#10854

Bug: 409577162
Change-Id: Ieee709ff15c13bdd0b1d7598e27031867062b592
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6443776
Reviewed-by: David Baron <dbaron@chromium.org>
Commit-Queue: Keith Cirkel <chromium@keithcirkel.co.uk>
Commit-Queue: David Baron <dbaron@chromium.org>
Auto-Submit: Keith Cirkel <chromium@keithcirkel.co.uk>
Cr-Commit-Position: refs/heads/main@{#1446589}

--

wpt-commits: 9546e2007adb73a3545fb61a5e5c8f754c6587e4
wpt-pr: 51977
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition/proposal New features or enhancements topic: custom elements Relates to custom elements (as defined in DOM and HTML) topic: shadow Relates to shadow trees (as defined in DOM)

Development

Successfully merging this pull request may close these issues.

Revamped Scoped Custom Element Registries (DOM side) Revamped Scoped Custom Element Registries

3 participants