mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 17:42:15 +08:00
fix(vue): modal, popover, and nav are now created within application context (#22282)
resolves #22079
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import { createVNode, render } from 'vue';
|
||||
|
||||
import { h, Teleport, VNode } from 'vue';
|
||||
import { addTeleportedUserComponent, removeTeleportedUserComponent } from './components/IonApp';
|
||||
export const VueDelegate = () => {
|
||||
const attachViewToDom = (parentElement: HTMLElement, component: any, componentProps: any, classes?: string[]) => {
|
||||
let Component: VNode | undefined;
|
||||
const attachViewToDom = (parentElement: HTMLElement, component: any, componentProps: any = {}, classes?: string[]) => {
|
||||
/**
|
||||
* Ionic Framework passes in modal and popover element
|
||||
* refs as props, but if these are not defined
|
||||
@ -10,20 +11,24 @@ export const VueDelegate = () => {
|
||||
*/
|
||||
delete componentProps['modal'];
|
||||
delete componentProps['popover'];
|
||||
const vueInstance = createVNode(component, componentProps);
|
||||
|
||||
const div = document.createElement('div');
|
||||
classes && div.classList.add(...classes);
|
||||
|
||||
parentElement.appendChild(div);
|
||||
|
||||
render(vueInstance, div);
|
||||
Component = h(
|
||||
Teleport,
|
||||
{ to: div },
|
||||
h(component, { ...componentProps })
|
||||
);
|
||||
|
||||
addTeleportedUserComponent(Component);
|
||||
|
||||
return div;
|
||||
}
|
||||
|
||||
const removeViewFromDom = (_: HTMLElement, childElement: any) => {
|
||||
render(null, childElement);
|
||||
const removeViewFromDom = () => {
|
||||
Component && removeTeleportedUserComponent(Component);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user