File tree 2 files changed +11
-14
lines changed
@headlessui-react/src/utils
@headlessui-vue/src/utils
2 files changed +11
-14
lines changed Original file line number Diff line number Diff line change @@ -3,12 +3,11 @@ import { env } from './env'
3
3
4
4
export function getOwnerDocument < T extends Element | MutableRefObject < Element | null > > (
5
5
element : T | null | undefined
6
- ) {
6
+ ) : Document | null {
7
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
- }
8
+ if ( ! element ) return document
9
+ if ( 'ownerDocument' in element ) return element . ownerDocument
10
+ if ( 'current' in element ) return element . current ?. ownerDocument ?? document
12
11
13
- return document
12
+ return null
14
13
}
Original file line number Diff line number Diff line change @@ -2,15 +2,13 @@ import type { Ref } from 'vue'
2
2
import { dom } from './dom'
3
3
import { env } from './env'
4
4
5
- export function getOwnerDocument < T extends HTMLElement | Ref < HTMLElement | null > > (
5
+ export function getOwnerDocument < T extends Element | Ref < Element | null > > (
6
6
element : T | null | undefined
7
- ) {
7
+ ) : Document | null {
8
8
if ( env . isServer ) return null
9
- if ( element instanceof Node ) return element . ownerDocument
10
- if ( element ?. hasOwnProperty ( 'value' ) ) {
11
- let domElement = dom ( element as any )
12
- if ( domElement ) return domElement . ownerDocument
13
- }
9
+ if ( ! element ) return document
10
+ if ( 'ownerDocument' in element ) return element . ownerDocument
11
+ if ( 'value' in element ) return dom ( element as any ) ?. ownerDocument ?? document
14
12
15
- return document
13
+ return null
16
14
}
You can’t perform that action at this time.
0 commit comments