Sign up (with export icon)

utils/dom/getlayoutparentelement

Api-module iconmodule

Functions

  • Chevron-right icon

    getLayoutParentElement( node ) → Element | null

    Returns the parent element in the flattened tree, the one the browser lays out and paints.

    The layout-aware counterpart of getParentElement, and the element-only form of getLayoutParentNode – see that one for why the flattened tree and the node tree disagree for slotted content, and for when to prefer which.

    Use it to walk outwards over the elements that lay a node out: its scrollable ancestors, its clipping ancestors. Works for open and closed roots alike, and falls back to the node tree for slotted content inside a closed root, whose slot the DOM standard does not expose.

    Parameters

    node: Node

    The node to get the layout parent element of.

    Returns

    Element | null