utils/dom/getpositionedancestor
Functions
getPositionedAncestor( element? ) → HTMLElement | nullmodule:utils/dom/getpositionedancestor~getPositionedAncestorReturns the element the given one is laid out against while absolutely positioned – the element whose padding box its
topandleftare relative to. Returnsnullwhen there is nothing to compensate for: the element is laid out against the initial containing block, isposition: fixed, or is not rendered at all.Use it when turning a position measured against the viewport into the
topandleftto set on an absolutely positioned element, by subtracting the returned element's padding-box offset – the waytoAbsoluteRectandgetOptimalPositiondo.The layout-aware counterpart of
Element#offsetParent, and what to reach for instead of it: this one follows the flattened tree, the one the browser lays out, so it stays right for slotted content – an editor slotted into a container component – whereoffsetParentnames an element that does not lay that content out. Falls back tooffsetParentfor slotted content inside a closed root, whose slot the DOM standard does not expose.Parameters
element?: HTMLElementThe native DOM element to be checked.
Returns
HTMLElement | null