From c17758994fe538180cd5cc2239606e77fefc9ecd Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Fri, 19 Feb 2021 17:07:05 +0100 Subject: [PATCH] add small dom utility to resolve the dom node from a ref --- packages/@headlessui-vue/src/utils/dom.ts | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 packages/@headlessui-vue/src/utils/dom.ts diff --git a/packages/@headlessui-vue/src/utils/dom.ts b/packages/@headlessui-vue/src/utils/dom.ts new file mode 100644 index 0000000000..32152f3a90 --- /dev/null +++ b/packages/@headlessui-vue/src/utils/dom.ts @@ -0,0 +1,7 @@ +import { Ref } from 'vue' + +export function dom(ref?: Ref): T | null { + if (ref == null) return null + if (ref.value == null) return null + return ((ref as Ref).value.$el ?? ref.value) as T | null +}