Skip to content

Commit

Permalink
add small dom utility to resolve the dom node from a ref
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Feb 19, 2021
1 parent c4549e4 commit c177589
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/@headlessui-vue/src/utils/dom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Ref } from 'vue'

export function dom<T extends HTMLElement>(ref?: Ref<T | null>): T | null {
if (ref == null) return null
if (ref.value == null) return null
return ((ref as Ref<T & { $el: unknown }>).value.$el ?? ref.value) as T | null
}

0 comments on commit c177589

Please sign in to comment.