Open History to see the last commit
1// Hidden kept views retain popup DOM and attributes; global checks must skip them.
2export function queryShownElement(selector: string): Element | null {
3 if (typeof document === "undefined") return null;
4 for (const element of document.querySelectorAll(selector)) {
5 const shown =
6 typeof element.checkVisibility === "function"
7 ? element.checkVisibility()
8 : element.getClientRects().length > 0;
9 if (shown) return element;
10 }
11 return null;
12}