Skip to content

Add shadowrootslotassignment attribute#43753

Merged
hamishwillee merged 16 commits into
mdn:mainfrom
keithamus:add-shadowrootslotassignment-attribute
May 17, 2026
Merged

Add shadowrootslotassignment attribute#43753
hamishwillee merged 16 commits into
mdn:mainfrom
keithamus:add-shadowrootslotassignment-attribute

Conversation

@keithamus
Copy link
Copy Markdown
Contributor

@keithamus keithamus commented Apr 12, 2026

Description

This adds docs for the shadowrootslotassignment attribute.

Motivation

Trying to add the docs so that whatwg/html#12267 can be merged.

Additional details

I've largely cribbed the docs style from the other shadowroot* attributes.

Related issues and pull requests

@keithamus keithamus requested review from a team as code owners April 12, 2026 09:38
@keithamus keithamus requested review from estelle and pepelsbey and removed request for a team April 12, 2026 09:38
@github-actions github-actions Bot added Content:HTML Hypertext Markup Language docs Content:WebAPI Web API docs labels Apr 12, 2026
@github-actions github-actions Bot added the size/s [PR only] 6-50 LoC changed label Apr 12, 2026
@pepelsbey
Copy link
Copy Markdown
Member

Thank you. Is there an existing browser implementation? It seems to be missing from BCD for now.

@pepelsbey
Copy link
Copy Markdown
Member

It seems like it's not implemented yet. So I would keep this PR open until the first experimental implementation lands, as we only document features supported by browsers. Thank you again for doing this in advance!

@keithamus keithamus force-pushed the add-shadowrootslotassignment-attribute branch from c4c9d81 to 01414b1 Compare April 12, 2026 09:58
Comment thread files/en-us/web/html/reference/elements/template/index.md Outdated
Comment thread files/en-us/web/html/reference/elements/template/index.md Outdated
Comment thread files/en-us/web/html/reference/elements/template/index.md
@keithamus
Copy link
Copy Markdown
Contributor Author

It seems like it's not implemented yet. So I would keep this PR open until the first experimental implementation lands, as we only document features supported by browsers. Thank you again for doing this in advance!

Right. https://groups.google.com/a/mozilla.org/g/dev-platform/c/8qxAHE9-Xdo is my intent to ship this in Firefox. I'll work on adding BCD definitions.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 12, 2026

@keithamus keithamus force-pushed the add-shadowrootslotassignment-attribute branch 4 times, most recently from ce2b217 to 24afef4 Compare April 12, 2026 10:11
Comment thread files/en-us/web/api/htmltemplateelement/shadowrootslotassignment/index.md Outdated
Comment thread files/en-us/web/api/htmltemplateelement/shadowrootslotassignment/index.md Outdated
Comment thread files/en-us/web/html/reference/elements/template/index.md
Comment thread files/en-us/web/api/shadowroot/slotassignment/index.md Outdated
@hamishwillee hamishwillee force-pushed the add-shadowrootslotassignment-attribute branch from 4893b1c to dab8147 Compare April 24, 2026 01:59
@hamishwillee
Copy link
Copy Markdown
Collaborator

@keithamus THanks for this. I'm supported to sort out docs for the FF151 release - have updated BCD and release note. Let me know what help you need to push this over the line.

@keithamus
Copy link
Copy Markdown
Contributor Author

@hamishwillee happy to have you take over this PR if you have time. I won’t be able to get to it until late next week or so.

@hamishwillee
Copy link
Copy Markdown
Collaborator

hamishwillee commented May 12, 2026

From #43753 (comment)

The element could use manual slot assignment to detect a change event in the select, and slot only the elements who's data-genre matches, thereby not rendering elements that don't match.

Thanks @keithamus . I've tried to integrate your comments in the section added in https://github.com/mdn/content/pull/43753/changes#r3224439661 - it updates the slots guide, which I think needed this.

@keithamus Can you please check this ALL sometime soon? I can merge it of course, as I have the power, but it isn't right that I should do so without you checking it. I am happy with it "broadly"

Copy link
Copy Markdown
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

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

@hamishwillee I had a look around as requested, and ended up doing a full review ;-)

Really interesting stuff.

- `mode`
- : A string specifying the _encapsulation mode_ for the shadow DOM tree.
This can be one of:
- `open`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These descriptions should be pared down, and the code snippets placed in an explainer section in the "Description".

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good idea. Fixed in 559fd27

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great

Comment thread files/en-us/web/api/element/attachshadow/index.md Outdated
Comment thread files/en-us/web/api/element/attachshadow/index.md Outdated
Comment thread files/en-us/web/api/htmltemplateelement/shadowrootslotassignment/index.md Outdated
Comment thread files/en-us/web/api/htmltemplateelement/shadowrootslotassignment/index.md Outdated
Comment thread files/en-us/web/api/web_components/using_templates_and_slots/index.md Outdated
Comment thread files/en-us/web/api/web_components/using_templates_and_slots/index.md Outdated
Comment thread files/en-us/web/api/web_components/using_templates_and_slots/index.md Outdated
Comment thread files/en-us/web/api/web_components/using_templates_and_slots/index.md Outdated
Comment thread files/en-us/web/api/web_components/using_templates_and_slots/index.md Outdated
Comment thread files/en-us/web/api/element/attachshadow/index.md Outdated
customElements.define("my-custom-element", MyCustomElement);
```

### Shadow DOM with named slot assignment
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Given this is the default, this example feels a little verbose:

  1. named slot assignment is quite well supported (I think back to Safari 10, Firefox 63, Chrome 53 or so?)
  2. The slotAssignment IDL is only recently supported due to the addition of manual slot assignment, so that seems like a more relevant example - especially when it comes to feature detection.

Copy link
Copy Markdown
Collaborator

@hamishwillee hamishwillee May 15, 2026

Choose a reason for hiding this comment

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

Fair enough. What I have done here is simplied the example to remove the feature test and not even specify the slot assignment. It is still worth showing.

Then I have added a second example that shows the manual assignment - same output but done manually.
It is not a great example of the possibilities - we should improve the example in the Using template and slots guide for that (a job for another day). However it does show quite clearly how it works.

Comment thread files/en-us/web/api/element/attachshadow/index.md Outdated
Comment thread files/en-us/web/api/htmltemplateelement/shadowrootslotassignment/index.md Outdated
Comment thread files/en-us/web/api/shadowroot/slotassignment/index.md Outdated
Comment thread files/en-us/web/api/web_components/using_templates_and_slots/index.md Outdated
Comment thread files/en-us/web/api/web_components/using_templates_and_slots/index.md Outdated
Comment thread files/en-us/web/html/reference/elements/slot/index.md Outdated
Comment thread files/en-us/web/html/reference/elements/template/index.md Outdated
@hamishwillee hamishwillee force-pushed the add-shadowrootslotassignment-attribute branch from fbc8a20 to 1ff77a4 Compare May 15, 2026 02:18
@hamishwillee
Copy link
Copy Markdown
Collaborator

Thanks @chrisdavidmills and @keithamus - I've done fixes for all of this. I think a lot better. One possible further change (in addition to whatever else you need) is possibly choosing to refer to "unnamed" as "manual"? It is easier to parse as a reader.

Copy link
Copy Markdown
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

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

This all looks fine from my perspective. I won't merge yet, but I will approve to avoid blocking further progress.

@hamishwillee
Copy link
Copy Markdown
Collaborator

Thanks @chrisdavidmills . I'm going to merge as it is much more clear than what preceded it. Certainly more could be done but I'd like to get what we have here in for the FF151 release tomorrow.

@keithamus If you have further comments, in particular to the idea in #43753 (comment), they would be welcome but we can do as a post process. Thanks for kicking this off too - saved a lot of time.

@hamishwillee hamishwillee merged commit f77236a into mdn:main May 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:HTML Hypertext Markup Language docs Content:WebAPI Web API docs size/l [PR only] 501-1000 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants