HTMLSlotElement.assignedElements()

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: A Boolean indicating whether to return the assigned elements of any available child <slot> elements (true) or not (false). Defaults to false.

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

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
assignedElements
Experimental
Chrome Full support 65Edge Full support 79Firefox Full support 66IE No support NoOpera Full support YesSafari ? WebView Android Full support 65Chrome Android Full support 65Firefox Android Full support 66Opera Android Full support YesSafari 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.