We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
getOwnerDocument
1 parent 1f756a3 commit 642061aCopy full SHA for 642061a
packages/@headlessui-react/src/utils/owner.ts
@@ -3,12 +3,11 @@ import { env } from './env'
3
4
export function getOwnerDocument<T extends Element | MutableRefObject<Element | null>>(
5
element: T | null | undefined
6
-) {
+): Document | null {
7
if (env.isServer) return null
8
- if (element instanceof Node) return element.ownerDocument
9
- if (element?.hasOwnProperty('current')) {
10
- if (element.current instanceof Node) return element.current.ownerDocument
11
- }
+ if (!element) return document
+ if ('ownerDocument' in element) return element.ownerDocument
+ if ('current' in element) return element.current?.ownerDocument ?? null
12
13
- return document
+ return null
14
}
0 commit comments