]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: refactor
authordaiwei <daiwei521@126.com>
Fri, 7 Mar 2025 06:55:24 +0000 (14:55 +0800)
committerdaiwei <daiwei521@126.com>
Fri, 7 Mar 2025 06:55:24 +0000 (14:55 +0800)
packages/runtime-core/src/apiCreateApp.ts
packages/runtime-core/src/components/BaseTransition.ts
packages/runtime-core/src/renderer.ts
packages/runtime-vapor/src/vdomInterop.ts

index 30042368aff7eaf93d2233c3ce835d84e17d791b..3cf807964e1d24f6928da49585dcac93959f70f9 100644 (file)
@@ -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
index e2f9bdf26b55bae038621ec123a95c4bcea0c13c..477c545ad6501c46fcf05892be9efabb23edb783 100644 (file)
@@ -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<T = () => 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)
index 39205ab1eac1c7a8b61a8e7b98c5f6b443b268e5..5b1a50846926ee5e4b990323714f3b7836f8359c 100644 (file)
@@ -2666,7 +2666,7 @@ export function performTransitionLeave(
   }
 }
 
-function getVaporInterface(
+export function getVaporInterface(
   instance: ComponentInternalInstance | null,
   vnode: VNode,
 ): VaporInteropInterface {
index 4724b302ce12b706c4564a082c6acb10646fdb57..0b17b4729221cc3a6d7d8704a190435361205076 100644 (file)
@@ -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<