This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
The assignedElements() method of the HTMLSlotElement interface returns a sequence of the elements assigned to this slot (and no other nodes).
If the flatten option is set to true, it returns a sequence of both the elements assigned to this slot, as well as the elements assigned to any other slots that are descendants of this slot. If no assigned elements are found, it returns the slot's fallback content.
assignedElements() assignedElements(options)
options OptionalAn object that sets options for the nodes to be returned. The available options are:
flattenA boolean value indicating whether to return the assigned elements of any available child <slot> elements (true) or not (false). Defaults to false.
An array of elements.
let slots = this.shadowRoot.querySelector("slot");
let elements = slots.assignedElements({ flatten: true });
| Specification |
|---|
| HTML> # dom-slot-assignedelements-dev> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
assignedElements |
65 | 79 | 66 | 52 | 12.1 | 65 | 66 | 47 | 12.2 | 9.0 | 65 | 12.2 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLSlotElement/assignedElements