The assignedElements()
property 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 also returns the assigned elements of any other slots that are descendants of this slot. If no assigned nodes are found, it returns the slot's fallback content.
Syntax
var assignedElements = HTMLSlotElement.assignedElements(options)
Parameters
- options Optional
- An object that sets options for the nodes to be returned. The available options are:
flatten
: ABoolean
indicating whether to return the assigned elements of any available child<slot>
elements (true
) or not (false
). Defaults tofalse
.
Return value
An array of elements.
Examples
let slots = this.shadowRoot.querySelector('slot'); let elements = slots.assignedElements({flatten: true});
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'assignedElements()' in that specification. |
Living Standard |
Browser Compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
assignedElements | Chrome Full support 65 | Edge Full support 79 | Firefox Full support 66 | IE No support No | Opera Full support Yes | Safari ? | WebView Android Full support 65 | Chrome Android Full support 65 | Firefox Android Full support 66 | Opera Android Full support Yes | Safari iOS ? | Samsung Internet Android Full support 9.0 |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.