Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

385 B
Raw Blame
// Credit: https://github.com/tailwindlabs/headlessui/
import type { Ref, ComponentPublicInstance } from "vue"

export function getDomElement<T extends Element | ComponentPublicInstance>(
  ref?: Ref<T | null>
): T | null {
  if (ref == null) {
    return null
  }
  if (ref.value == null) {
    return null
  }

  return "$el" in ref.value ? (ref.value.$el as T | null) : ref.value
}