GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • MDN
  • HTML: Markup language
  • Elements
  • Global attributes
  • Attributes
  • See all…
  • Responsive images
  • HTML cheatsheet
  • Date & time formats
  • See all…
  • SVG
  • MathML
  • XML
  • CSS: Styling language

This view

  • Original page
  • New address

GeezerVison is showing developer.mozilla.org — HTMLSlotElement: assignedNodes() method - Web APIs | MDN

HTMLSlotElement: assignedNodes() method

Baseline
Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

  • See full compatibility
  • Learn more

The assignedNodes() method of the HTMLSlotElement interface returns a sequence of the nodes assigned to this slot.

If the flatten option is set to true, it returns a sequence of both the nodes assigned to this slot and the nodes assigned to any other slots that are descendants of this slot. If no assigned nodes are found, it returns the slot's fallback content.

Syntax

js
assignedNodes()
assignedNodes(options)

Parameters

options Optional

An object that sets options for the nodes to be returned. The available options are:

flatten

A boolean value indicating whether to return the assigned nodes of any available child <slot> elements (true) or not (false). Defaults to false.

Return value

An array of nodes.

Examples

The following snippet is taken from our slotchange example (See it live).

js
let slots = this.shadowRoot.querySelectorAll("slot");
slots[1].addEventListener("slotchange", (e) => {
  let nodes = slots[1].assignedNodes();
  console.log(
    `Element in Slot "${slots[1].name}" changed to "${nodes[0].outerHTML}".`,
  );
});

Here we grab references to all the slots, then add a slotchange event listener to the 2nd slot in the template — which is the one that keeps having its contents changed in the example.

Every time the element inserted in the slot changes, we log a report to the console saying which slot has changed, and what the new node inside the slot is.

Specifications

Specification
HTML
# dom-slot-assignednodes-dev

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on Sep 10, 2026 by MDN contributors.

View this page on GitHub • Report a problem with this content
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.