Skip to content

Add shadowrootslotassignment attribute - #12267

Merged
annevk merged 7 commits into
whatwg:mainfrom
keithamus:add-shadowrootslotassignment-attribute
Apr 15, 2026
Merged

annevk merged 7 commits into
whatwg:mainfrom
keithamus:add-shadowrootslotassignment-attribute

Conversation

@keithamus

@keithamus keithamus commented Mar 16, 2026 •

Copy link
Copy Markdown
Member

Implements the shadowrootslotassignment attribute.

Refs WICG/webcomponents#967

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


/indices.html ( diff )
/parsing.html ( diff )
/scripting.html ( diff )

@keithamus keithamus added agenda+ To be discussed at a triage meeting topic: custom elements Relates to custom elements (as defined in DOM and HTML) labels Mar 16, 2026
@keithamus

Copy link
Copy Markdown
Member Author

/cc @mfreed7

@rniwa

rniwa commented Mar 16, 2026

Copy link
Copy Markdown

It seems that we also need a mechanism to specify which nodes are assigned in what order.

@keithamus

Copy link
Copy Markdown
Member Author

It seems that we also need a mechanism to specify which nodes are assigned in what order.

Right. I think that it would be possible to ship the two independently, right? It's possible today to create a manual assignment shadowroot and never assign nodes.

@rniwa

rniwa commented Mar 16, 2026

Copy link
Copy Markdown

It seems that we also need a mechanism to specify which nodes are assigned in what order.

Right. I think that it would be possible to ship the two independently, right? It's possible today to create a manual assignment shadowroot and never assign nodes.

Maybe? It seems like we want some kind of plan for it before we this feature though.

@annevk annevk left a comment

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.

You also need to add the IDL attribute for the template element.

Comment thread source Outdated
@mfreed7

mfreed7 commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

/cc @mfreed7

This looks great to me! I could finally address this 4 year old Chromium TODO.

Right. I think that it would be possible to ship the two independently, right? It's possible today to create a manual assignment shadowroot and never assign nodes.

+1 - I think this PR provides perfect parity to the imperative attachShadow() call, which just sets the slotAssignment mode but doesn't actually assign nodes. That might be enough, in that it keeps slots from being automatically assigned to slots before the imperative code boots up and assigns them.

@keithamus

Copy link
Copy Markdown
Member Author

Maybe? It seems like we want some kind of plan for it before we this feature though.

AIUI the design described in WICG/webcomponents#967 adds a new attribute to slot elements. To me this stands to reason that these become opt-in, and therefore the design is additive - which is to say if we go with the proposed solution there, I believe they can ship independently.

So I don't think landing this now would close off the design space for us; landing this will not preclude us from the design in WICG/webcomponents#967, and I suspect it doesn't close off any other potential solutions in a way which would still make sense, but I'd be happy to be corrected on this.

@keithamus

Copy link
Copy Markdown
Member Author

I believe I've completed all the necessary steps for this to be merged, so all that's left is an editorial review. Please let me know if there's anything more to do here.

Thanks!

@annevk annevk left a comment

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.

If you contrast this with https://dom.spec.whatwg.org/#interface-shadowroot you see that slot assignment comes before clonable. I suggest we try to stick to that order.

@annevk

annevk commented Apr 12, 2026

Copy link
Copy Markdown
Member

I also noticed that the order is probably not tested as I changed the order in my implementation and still passed all the tests. (There is a test for it somewhere for the other attributes.)

Comment thread source Outdated
Comment thread source Outdated
Comment thread source
Comment thread source Outdated
Comment thread source Outdated

@annevk annevk left a comment

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.

Looks good modulo final formatting issue.

Comment thread source Outdated
<code data-x="attr-template-shadowrootclonable">shadowrootclonable</code>;
<code data-x="attr-template-shadowrootserializable">shadowrootserializable</code>;
<code data-x="attr-template-shadowrootcustomelementregistry">shadowrootcustomelementregistry</code></td>
<code data-x="attr-template-shadowrootslotassignment">shadowrootslotassignment</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.

The indentation seems wrong here. They all got an additional leading space?

we hardly knew ye
@annevk
annevk merged commit 7fe76d0 into whatwg:main Apr 15, 2026
2 checks passed
@keithamus
keithamus deleted the add-shadowrootslotassignment-attribute branch April 15, 2026 16:35
github-merge-queue Bot pushed a commit to servo/servo that referenced this pull request Apr 19, 2026
This brings up to date with the specification for declarative shadow
roots: whatwg/html#12267.

The `shadowrootslotassignment` attribute on `<template>` elements
specifies the slot assignment mode used by the declarative shadow root
created by the template.

Testing: New tests start to pass

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
github-merge-queue Bot pushed a commit to servo/servo that referenced this pull request Apr 19, 2026
This brings up to date with the specification for declarative shadow
roots: whatwg/html#12267.

The `shadowrootslotassignment` attribute on `<template>` elements
specifies the slot assignment mode used by the declarative shadow root
created by the template.

Testing: New tests start to pass

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
github-merge-queue Bot pushed a commit to servo/servo that referenced this pull request Apr 19, 2026
This brings up to date with the specification for declarative shadow
roots: whatwg/html#12267.

The `shadowrootslotassignment` attribute on `<template>` elements
specifies the slot assignment mode used by the declarative shadow root
created by the template.

Testing: New tests start to pass

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
github-merge-queue Bot pushed a commit to servo/servo that referenced this pull request Apr 19, 2026
This brings up to date with the specification for declarative shadow
roots: whatwg/html#12267.

The `shadowrootslotassignment` attribute on `<template>` elements
specifies the slot assignment mode used by the declarative shadow root
created by the template.

Testing: New tests start to pass

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
brave-builds pushed a commit to brave/chromium that referenced this pull request Jul 2, 2026
Add the `shadowrootslotassignment` content attribute to HTML, as well as
the `shadowRootSlotAssignment` IDL attribute to HTMLTemplateElement.

The attribute has two valid values, "named" (default) and "manual".
Any other value, including a missing attribute, resolves to "named".

The HTML parser selects manual slot assignment mode only when the
attribute is in the "manual" state. Serialization emits
shadowrootslotassignment="manual" for a manual-mode shadow root, and
omits the attribute otherwise ("named").

Gated behind the ShadowRootSlotAssignment runtime flag ("experimental").

See: whatwg/html#12267

Tests:
/external/wpt/shadow-dom/declarative/declarative-shadow-dom-repeats-slot-assignment.html
/external/wpt/shadow-dom/declarative/declarative-shadow-dom-slot-assignment.html
/external/wpt/shadow-dom/declarative/declarative-shadow-dom-slot-assignment-serialization.html

ChromeStatus: https://chromestatus.com/feature/5178682139344896
Bug: 493315747
Change-Id: Ibbdc390ae3ce71a5a15c7fadc77b5aacb0e20ab9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7893946
Commit-Queue: Felipe Erias <felipeerias@igalia.com>
Reviewed-by: Mason Freed <masonf@chromium.org>
Reviewed-by: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1656030}
beckysiegel pushed a commit to chromium/chromium that referenced this pull request Jul 16, 2026
Ship the `shadowrootslotassignment` attribute, which lets declarative
shadow roots opt into manual slot assignment.

Spec: whatwg/html#12267
ChromeStatus: https://chromestatus.com/feature/5178682139344896
I2S: https://groups.google.com/a/chromium.org/d/msgid/blink-dev/6a3e71b6.cff415cc.dde5e.00b1.GAE%40google.com
Bug: 493315747
Change-Id: Id091cbc738b27b0c7d3268e5c75529e9a309e848
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8084149
Reviewed-by: David Baron <dbaron@chromium.org>
Commit-Queue: Felipe Erias <felipeerias@igalia.com>
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1662958}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: custom elements Relates to custom elements (as defined in DOM and HTML)

Development

Successfully merging this pull request may close these issues.

5 participants