Web APIs

HTMLSlotElement.prototype.assignedNodes()

Try the free JavaScript compiler

Returns assigned slottable nodes, including text nodes; optional flatten affects nested slots and fallback.

Formal Syntax & Structure

javascript syntaxjavascript
slot.assignedNodes([options])

Parameters & Attributes

NameTypeDescription
optionsobjectOptional flatten flag.

Return Value

Node[]

Returns assigned slottable nodes, including text nodes; optional flatten affects nested slots and fallback.

Working Example

Example Snippetjavascript
(async () => {const host=document.createElement("div");const root=host.attachShadow({mode:"open"});root.innerHTML="<slot>fallback</slot>";host.append(document.createTextNode("hello"));document.body.append(host);const slot=root.querySelector("slot");console.log(slot.assignedNodes()[0].nodeType,slot.assignedElements().length);})()
JavaScript Reference