import { ownerDocument } from "./owner-document"; /** * Returns the window that owns `node`, falling back to the ambient `window` * global when `node` is null or detached. Use this instead of reading * `window` directly so realm-sensitive checks (`node instanceof * win.HTMLElement`) work across iframes. */ export function ownerWindow(node: Node | null | undefined): Window { const doc = ownerDocument(node); return doc.defaultView ?? window; }