Files
eewing ec317eb17c
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m11s
INIT
2026-02-18 15:17:47 -06:00

21 lines
732 B
JavaScript

export function getFirstNonCommentChild(element) {
if (!element)
return null;
for (const child of element.childNodes) {
if (child.nodeType !== Node.COMMENT_NODE) {
return child;
}
}
return null;
}
/**
* Determines if the click event truly occurred outside the content node.
* This was added to handle password managers and other elements that may be injected
* into the DOM but visually appear inside the content.
*/
export function isClickTrulyOutside(event, contentNode) {
const { clientX, clientY } = event;
const rect = contentNode.getBoundingClientRect();
return (clientX < rect.left || clientX > rect.right || clientY < rect.top || clientY > rect.bottom);
}