UNPKG

@qntm-code/utils

Version:

A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.

17 lines (16 loc) 460 B
/** * Gets the first parent element with a relative or absolute position */ export function getPositionedParent(element) { const parent = element.parentElement; if (parent) { const style = window.getComputedStyle(parent); if (['relative', 'absolute'].includes(style.position)) { return parent; } else { return getPositionedParent(parent); } } return document.documentElement; }