fix(vue): cache attached view reference (#26694)

Resolves #26695
This commit is contained in:
Sean Perkins
2023-01-30 15:58:03 -05:00
committed by GitHub
parent 69d89eae94
commit 7c0089718a
6 changed files with 119 additions and 9 deletions

View File

@ -17,7 +17,7 @@ export const VueDelegate = (
// TODO(FW-2969): types
const attachViewToDom = (
parentElement: HTMLElement,
component: any,
componentOrTagName: any | string,
componentProps: any = {},
classes?: string[]
) => {
@ -28,10 +28,17 @@ export const VueDelegate = (
const hostComponent = h(
Teleport,
{ to: div },
h(component, { ...componentProps })
h(componentOrTagName, { ...componentProps })
);
refMap.set(component, hostComponent);
/**
* Ionic Framework will use what is returned from `attachViewToDom`
* as the `component` argument in `removeViewFromDom`.
*
* We will store a reference to the div element and the host component,
* so we can later look-up and unmount the correct instance.
*/
refMap.set(div, hostComponent);
addFn(hostComponent);