From: daiwei Date: Fri, 7 Mar 2025 06:55:24 +0000 (+0800) Subject: wip: refactor X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=915e2059bf451f51e6eec966fd4d12f8e6f6e121;p=thirdparty%2Fvuejs%2Fcore.git wip: refactor --- diff --git a/packages/runtime-core/src/apiCreateApp.ts b/packages/runtime-core/src/apiCreateApp.ts index 30042368af..3cf807964e 100644 --- a/packages/runtime-core/src/apiCreateApp.ts +++ b/packages/runtime-core/src/apiCreateApp.ts @@ -27,7 +27,7 @@ import { warn } from './warning' import type { VNode } from './vnode' import { devtoolsInitApp, devtoolsUnmountApp } from './devtools' import { NO, extend, isFunction, isObject } from '@vue/shared' -import { version } from '.' +import { type TransitionHooks, version } from '.' import { installAppCompatProperties } from './compat/global' import type { NormalizedPropsOptions } from './componentProps' import type { ObjectEmitsOptions } from './componentEmits' @@ -193,6 +193,10 @@ export interface VaporInteropInterface { unmount(vnode: VNode, doRemove?: boolean): void move(vnode: VNode, container: any, anchor: any): void slot(n1: VNode | null, n2: VNode, container: any, anchor: any): void + setTransitionHooks( + component: ComponentInternalInstance, + transition: TransitionHooks, + ): void vdomMount: (component: ConcreteComponent, props?: any, slots?: any) => any vdomUnmount: UnmountComponentFn diff --git a/packages/runtime-core/src/components/BaseTransition.ts b/packages/runtime-core/src/components/BaseTransition.ts index e2f9bdf26b..477c545ad6 100644 --- a/packages/runtime-core/src/components/BaseTransition.ts +++ b/packages/runtime-core/src/components/BaseTransition.ts @@ -1,6 +1,7 @@ import { type ComponentInternalInstance, type ComponentOptions, + type ConcreteComponent, type GenericComponentInstance, type SetupContext, getCurrentInstance, @@ -20,7 +21,7 @@ import { ErrorCodes, callWithAsyncErrorHandling } from '../errorHandling' import { PatchFlags, ShapeFlags, isArray, isFunction } from '@vue/shared' import { onBeforeUnmount, onMounted } from '../apiLifecycle' import { isTeleport } from './Teleport' -import type { RendererElement } from '../renderer' +import { type RendererElement, getVaporInterface } from '../renderer' import { SchedulerJobFlags } from '../scheduler' type Hook void> = T | T[] @@ -566,8 +567,11 @@ function getInnerChild(vnode: VNode): VNode | undefined { export function setTransitionHooks(vnode: VNode, hooks: TransitionHooks): void { if (vnode.shapeFlag & ShapeFlags.COMPONENT && vnode.component) { - if ((vnode.type as any).__vapor) { - ;(vnode.component as any).block.$transition = hooks + if ((vnode.type as ConcreteComponent).__vapor) { + getVaporInterface(vnode.component, vnode).setTransitionHooks( + vnode.component, + hooks, + ) } else { vnode.transition = hooks setTransitionHooks(vnode.component.subTree, hooks) diff --git a/packages/runtime-core/src/renderer.ts b/packages/runtime-core/src/renderer.ts index 39205ab1ea..5b1a508469 100644 --- a/packages/runtime-core/src/renderer.ts +++ b/packages/runtime-core/src/renderer.ts @@ -2666,7 +2666,7 @@ export function performTransitionLeave( } } -function getVaporInterface( +export function getVaporInterface( instance: ComponentInternalInstance | null, vnode: VNode, ): VaporInteropInterface { diff --git a/packages/runtime-vapor/src/vdomInterop.ts b/packages/runtime-vapor/src/vdomInterop.ts index 4724b302ce..0b17b47292 100644 --- a/packages/runtime-vapor/src/vdomInterop.ts +++ b/packages/runtime-vapor/src/vdomInterop.ts @@ -128,6 +128,10 @@ const vaporInteropImpl: Omit< insert(vnode.vb || (vnode.component as any), container, anchor) insert(vnode.anchor as any, container, anchor) }, + + setTransitionHooks(component, hooks) { + setTransitionToInstance(component as any, hooks as VaporTransitionHooks) + }, } const vaporSlotPropsProxyHandler: ProxyHandler<