Sign up (with export icon)

utils/dom/getlayoutparentnode

Api-module iconmodule

Functions

  • Chevron-right icon

    getLayoutParentNode( node ) → ParentNode | null

    Returns the node one step up the flattened tree, the one the browser lays out and paints.

    The layout-aware counterpart of getParentNode, which walks the node tree. The two agree everywhere except for slotted content: assigning a node to a <slot> does not move it, so it stays a child of the host in the node tree while rendering inside the slot. A node-tree walk out of such a node therefore leaves into the light DOM and skips every element of the shadow tree that actually lays it out.

    Use this one for questions about geometry – what scrolls a node, what clips it, what it renders inside – and getParentNode for questions about structure, such as what a node is a descendant of for the purposes of DOM manipulation or event retargeting. Both cross shadow boundaries and both work for open and closed roots alike.

    Note: Element#assignedSlot is null when the slot lives in a closed shadow root, which the DOM standard does not expose. For slotted content inside a closed root this falls back to the node tree and answers exactly as getParentNode does.

    Parameters

    node: Node

    The node to step up from.

    Returns

    ParentNode | null