MCPcopy Create free account
hub / github.com/adobe/react-spectrum / getOwnerDocument

Function getOwnerDocument

packages/react-aria/src/utils/domHelpers.ts:16–23  ·  view source on GitHub ↗
(target?: EventTarget | null)

Source from the content-addressed store, hash-verified

14import {isDocument, isWindow} from './typeHelpers';
15
16export const getOwnerDocument = (target?: EventTarget | null): Document => {
17 if (isWindow(target)) return target.document;
18
19 if (isDocument(target)) return target;
20
21 // @ts-expect-error Ensure safe access in SSR environments.
22 return target?.ownerDocument ?? (typeof document !== 'undefined' ? document : undefined);
23};
24
25export const getOwnerWindow = (target?: EventTarget | null): Window & typeof globalThis => {
26 let ownerDocument = getOwnerDocument(target);

Callers 15

domHelpers.test.jsFile · 0.90
useInteractOutsideFunction · 0.90
useFocusFunction · 0.90
focusSafelyFunction · 0.90
onKeyDownFunction · 0.90
usePressFunction · 0.90
handleFocusEventFunction · 0.90
handleInvalidEventFunction · 0.90
setupGlobalFocusEventsFunction · 0.90
addWindowFocusTrackingFunction · 0.90
isKeyboardFocusEventFunction · 0.90

Calls 2

isWindowFunction · 0.90
isDocumentFunction · 0.90

Tested by

no test coverage detected