From abc7ce75b0c78d0b18305846a23ebc31c19bb6de Mon Sep 17 00:00:00 2001 From: Georges KABBOUCHI Date: Sat, 12 Jun 2021 00:10:58 +0300 Subject: [PATCH] clone vue appContext in useTippy --- src/composables/useTippy.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/composables/useTippy.ts b/src/composables/useTippy.ts index 662b5d8..087306c 100644 --- a/src/composables/useTippy.ts +++ b/src/composables/useTippy.ts @@ -29,6 +29,7 @@ export function useTippy( mount: boolean } = { mount: true } ) { + const vm = getCurrentInstance() const instance = ref() let container: Element | null = null @@ -49,10 +50,21 @@ export function useTippy( : content if (isVNode(unwrappedContent)) { + if (vm) { + unwrappedContent.appContext = vm.appContext + } + render(unwrappedContent, getContainer()) newContent = () => getContainer() } else if (typeof unwrappedContent === 'object') { - render(h(unwrappedContent), getContainer()) + let comp = h(unwrappedContent) + + if (vm) { + comp.appContext = vm.appContext + } + + render(comp, getContainer()) + newContent = () => getContainer() } else { newContent = unwrappedContent @@ -169,8 +181,6 @@ export function useTippy( } if (settings.mount) { - const vm = getCurrentInstance() - if (vm) { if (vm.isMounted) { mount()