7195eeed1a
* add small dom utility to resolve the dom node from a ref * use dom() to resolve underlying DOM node There is probably a better way to do this, the idea is that we apply a ref to the component. However by default for html components `yourRef.value` will be the underlying DOM node. However if you pass the ref to another component, the actual DOM node will be located at `yourRef.value.$el`. Fixes: #21 * update changelog
8 lines
254 B
TypeScript
8 lines
254 B
TypeScript
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
|
|
}
|