mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 17:42:15 +08:00
chore(vue): add eslint and prettier (#26635)
This commit is contained in:
@ -1,40 +1,48 @@
|
||||
import { h, Teleport, VNode } from 'vue';
|
||||
import type { FrameworkDelegate } from '@ionic/core/components';
|
||||
import type { FrameworkDelegate } from "@ionic/core/components";
|
||||
import type { VNode } from "vue";
|
||||
import { h, Teleport } from "vue";
|
||||
|
||||
import { addTeleportedUserComponent, removeTeleportedUserComponent } from './components/IonApp';
|
||||
import {
|
||||
addTeleportedUserComponent,
|
||||
removeTeleportedUserComponent,
|
||||
} from "./components/IonApp";
|
||||
|
||||
export const VueDelegate = (addFn = addTeleportedUserComponent, removeFn = removeTeleportedUserComponent): FrameworkDelegate => {
|
||||
export const VueDelegate = (
|
||||
addFn = addTeleportedUserComponent,
|
||||
removeFn = removeTeleportedUserComponent
|
||||
): FrameworkDelegate => {
|
||||
let Component: VNode | undefined;
|
||||
// TODO(FW-2969): types
|
||||
const attachViewToDom = (parentElement: HTMLElement, component: any, componentProps: any = {}, classes?: string[]) => {
|
||||
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
|
||||
* on the Vue component instance as props, Vue will
|
||||
* warn the user.
|
||||
*/
|
||||
delete componentProps['modal'];
|
||||
delete componentProps['popover'];
|
||||
delete componentProps["modal"];
|
||||
delete componentProps["popover"];
|
||||
|
||||
const div = document.createElement('div');
|
||||
const div = document.createElement("div");
|
||||
classes && div.classList.add(...classes);
|
||||
parentElement.appendChild(div);
|
||||
|
||||
Component = h(
|
||||
Teleport,
|
||||
{ to: div },
|
||||
h(component, { ...componentProps })
|
||||
);
|
||||
Component = h(Teleport, { to: div }, h(component, { ...componentProps }));
|
||||
|
||||
addFn(Component);
|
||||
|
||||
return Promise.resolve(div);
|
||||
}
|
||||
};
|
||||
|
||||
const removeViewFromDom = () => {
|
||||
Component && removeFn(Component);
|
||||
return Promise.resolve();
|
||||
}
|
||||
};
|
||||
|
||||
return { attachViewToDom, removeViewFromDom }
|
||||
}
|
||||
return { attachViewToDom, removeViewFromDom };
|
||||
};
|
||||
|
Reference in New Issue
Block a user