Skip to content

Commit 0951cce

Browse files
committed
fix unref element
1 parent 6f8f32f commit 0951cce

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-tippy",
3-
"version": "6.1.1",
3+
"version": "6.1.2",
44
"main": "index.js",
55
"module": "dist/vue-tippy.mjs",
66
"unpkg": "dist/vue-tippy.iife.js",

playground/pages/Wga.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<template>
22
<div>
33
<tippy content="Choose an aggregation for this area" :tag="null">
4-
<button class="text-sm py-2 px-3 bg-gray-900 text-white rounded-lg">Aggregation #1</button>
4+
<button class="text-sm py-2 px-3 bg-gray-900 text-white rounded-lg">Aggregation #1</button>
5+
</tippy>
6+
7+
<tippy content="View Android device page" :tag="null">
8+
<RouterLink to="/" aria-label="View Android device page">
9+
Link
10+
</RouterLink>
511
</tippy>
612
</div>
713
</template>

src/components/Tippy.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ declare module '@vue/runtime-core' {
1313
interface ComponentCustomProperties extends UnwrapNestedRefs<ReturnType<typeof useTippy>> { }
1414
}
1515

16+
function toValue(r: any): any {
17+
return typeof r === 'function'
18+
? (r as any)()
19+
: unref(r)
20+
}
21+
function unrefElement(elRef: any): any {
22+
const plain = toValue(elRef)
23+
return (plain as any)?.$el ?? plain
24+
}
1625

1726
const TippyComponent = defineComponent({
1827
props: {
@@ -95,7 +104,7 @@ const TippyComponent = defineComponent({
95104
return options
96105
}
97106

98-
let target: any = () => elem.value
107+
let target: any = () => unrefElement(elem)
99108

100109
if (props.to) {
101110
if (typeof Element !== 'undefined' && props.to instanceof Element) {

0 commit comments

Comments
 (0)