Conversation
|
Thank you. Is there an existing browser implementation? It seems to be missing from BCD for now. |
|
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! |
c4c9d81 to
01414b1
Compare
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. |
Preview URLs (6 pages)External URLs (1)URL:
(comment last updated: 2026-04-28 04:23:34) |
ce2b217 to
24afef4
Compare
| The **`shadowRootSlotAssignment`** property of the {{domxref("HTMLTemplateElement")}} interface reflects the value of the [`shadowrootslotassignment`](/en-US/docs/Web/HTML/Reference/Elements/template#shadowrootslotassignment) attribute of the associated [`<template>`](/en-US/docs/Web/HTML/Reference/Elements/template) element. | ||
|
|
||
| Note that this property is not useful for developers. | ||
| If a `<template>` element is used to declaratively create a [`ShadowRoot`](/en-US/docs/Web/API/ShadowRoot), then this object and property do not exist. | ||
| Otherwise, if an `HTMLTemplateElement` is created, the value of this property is irrelevant because the object is not a shadow root and cannot subsequently be changed to a shadow root. It can be used to detect support for the declarative attribute. |
There was a problem hiding this comment.
This PR was was quite helpful for me while trying to figure how to assign shadowrootslotassignment into web-features. Thank you! But after reading this, it sounds like it does have some utility to developers and it might be better to start with that information. Something along these lines:
The
shadowRootSlotAssignmentproperty of theHTMLTemplateElementinterface reflects the value of theshadowrootslotassignmentattribute of the associated<template>element. You can use its existence to detect support for theshadowrootslotassignmentattribute.You can't use this to use this to change…
(This is a drive-by suggestion from someone who knows very, very little about the shadow DOM. Take it with a grain of salt. 😅)
There was a problem hiding this comment.
UPdated in 2f3331a to show the only use - feature checking
| If set, the shadow root may be serialized by calling the {{DOMxRef('Element.getHTML()')}} or {{DOMxRef('ShadowRoot.getHTML()')}} methods with the `options.serializableShadowRoots` parameter set `true`. | ||
| The value defaults to `false`. | ||
|
|
||
| - `shadowrootslotassignment` |
There was a problem hiding this comment.
I wasn't originally assigned to this PR, so I wasn't going to comment.
My problem with this PR is that after reading it I really don't understand what this feature actually does. I was hoping to find the information at this point. It looks like I would have to go to Element.attachShadow() for more detail. Perhaps just a little more detail here would be useful. If not, then all the other links to here need to also point to attachShadow() (including the JavaScript interfaces) to reduce the steps to finding examples etc.
On that note, and example below in this doc would be great.
There was a problem hiding this comment.
Two ways to do this now right? Something like ...
| The read-only **`slotAssignment`** property of the {{domxref("ShadowRoot")}} interface returns the _slot assignment mode_ for the shadow DOM tree. Nodes are either automatically assigned (`named`) or manually assigned (`manual`). | |
| The value of this property is defined using the `slotAssignment` option when calling {{domxref("Element.attachShadow()")}}, or using the [`shadowrootslotassignment` attribute](/en-US/docs/Web/HTML/Reference/Elements/template#shadowrootslotassignment) on {{htmleelement("template")}} when declaratively creating a shadow root. |
4893b1c to
dab8147
Compare
|
@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. |
|
@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. |
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
dab8147 to
9bee4a2
Compare
Hi @keithamus I've updated it "a bit" to what I consider a reasonable minimum - i.e. the point where I understand what is going on here:-) Specifically I've added examples to the template doc on how this is used, and also on attachShadow() - but only for the named slot assignment case. I know that doesn't actually "say" anything extra, but live examples are like a picture that tells many words. This needs your review, and then perhaps we should get an independent review from Vadim. What is missing though is some explanation of why you would ever use manual assignment. There must be good reasons, and it would be great to explain them - and when you would use/not use the feature. It might make sense to include this in https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements - that could then be the master copy we link to for this kind of stuff. |
Description
This adds docs for the
shadowrootslotassignmentattribute.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
HTMLTemplateElement.shadowrootslotassignmentattribute browser-compat-data#29457