Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Mar 28, 2023
1 parent 99feb31 commit a63f5f9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/core/useParentElement/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import type { MaybeComputedRef } from '@vueuse/shared'
import { resolveUnref, tryOnMounted } from '@vueuse/shared'
import type { Ref } from 'vue-demi'
import { getCurrentInstance, shallowRef, watch } from 'vue-demi'
import { shallowRef, watch } from 'vue-demi'
import { unrefElement } from '../unrefElement'
import { useCurrentElement } from '../useCurrentElement'

export function useParentElement(
element?: MaybeComputedRef<HTMLElement | SVGElement | null | undefined>,
element: MaybeComputedRef<HTMLElement | SVGElement | null | undefined> = useCurrentElement<HTMLElement | SVGAElement>(),
): Readonly<Ref<HTMLElement | SVGElement | null | undefined>> {
const parentElement = shallowRef<HTMLElement | SVGElement | null | undefined>()

const update = () => {
const el = unrefElement(element ? resolveUnref(element) : getCurrentInstance()?.proxy)
const el = unrefElement(element)
if (el)
parentElement.value = el.parentElement
}
Expand Down

0 comments on commit a63f5f9

Please sign in to comment.