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

Function getOwnerDocument

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

Source from the content-addressed store, hash-verified

13import type {EventMapType} from '@react-types/shared';
14
15export const getOwnerDocument = (target?: EventTarget | null): Document => {
16 if (isWindow(target)) return target.document;
17
18 if (isDocument(target)) return target;
19
20 // @ts-expect-error Ensure safe access in SSR environments.
21 return target?.ownerDocument ?? (typeof document !== 'undefined' ? document : undefined);
22};
23
24export const getOwnerWindow = (target?: EventTarget | null): Window & typeof globalThis => {
25 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
setupGlobalFocusEventsFunction · 0.90
addWindowFocusTrackingFunction · 0.90
isKeyboardFocusEventFunction · 0.90
disableTextSelectionFunction · 0.90

Calls 2

isWindowFunction · 0.85
isDocumentFunction · 0.70

Tested by

no test coverage detected