in src/anchored-position.ts [178:213]
function getClippingRect(element: Element): BoxPosition {
let parentNode: typeof element.parentNode = element
while (parentNode !== null) {
if (parentNode === document.body) {
break
}
const parentNodeStyle = getComputedStyle(parentNode as Element)
if (parentNodeStyle.overflow !== 'visible') {
break
}
parentNode = parentNode.parentNode
}
const clippingNode = parentNode === document.body || !(parentNode instanceof HTMLElement) ? document.body : parentNode
const elemRect = clippingNode.getBoundingClientRect()
const elemStyle = getComputedStyle(clippingNode)
const [borderTop, borderLeft, borderRight, borderBottom] = [
elemStyle.borderTopWidth,
elemStyle.borderLeftWidth,
elemStyle.borderRightWidth,
elemStyle.borderBottomWidth
].map(v => parseInt(v, 10) || 0)
return {
top: elemRect.top + borderTop,
left: elemRect.left + borderLeft,
width: elemRect.width - borderRight - borderLeft,
// If the clipping node is document.body, it can expand to the full height of the window
height: Math.max(
elemRect.height - borderTop - borderBottom,
clippingNode === document.body ? window.innerHeight : -Infinity
)
}
}