Web APIs
HTMLSlotElement.prototype.assignedNodes()
Returns assigned slottable nodes, including text nodes; optional flatten affects nested slots and fallback.
Formal Syntax & Structure
javascript syntaxjavascript
slot.assignedNodes([options])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| options | object | Optional 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);})()