From: edison Date: Mon, 14 Apr 2025 02:20:25 +0000 (+0800) Subject: Merge branch 'vapor' into edison/feat/vaporKeepAlive X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82ad930a67ef0af214bd596d20f6f687f9538398;p=thirdparty%2Fvuejs%2Fcore.git Merge branch 'vapor' into edison/feat/vaporKeepAlive --- 82ad930a67ef0af214bd596d20f6f687f9538398 diff --cc packages/runtime-core/src/components/KeepAlive.ts index 0a88a3303e,d18d5a48b8..6fc70e88c9 --- a/packages/runtime-core/src/components/KeepAlive.ts +++ b/packages/runtime-core/src/components/KeepAlive.ts @@@ -439,86 -491,3 +439,92 @@@ export function resetShapeFlag(vnode: a function getInnerChild(vnode: VNode) { return vnode.shapeFlag & ShapeFlags.SUSPENSE ? vnode.ssContent! : vnode } + +/** + * shared between runtime-core and runtime-vapor + */ +export function activate( + vnode: VNode, + container: RendererElement, + anchor: RendererNode | null, + { p: patch, m: move }: RendererInternals, + parentComponent: ComponentInternalInstance | null, + parentSuspense: SuspenseBoundary | null, + namespace?: ElementNamespace, + optimized?: boolean, +): void { + const instance = vnode.component! + move( + vnode, + container, + anchor, + MoveType.ENTER, + parentComponent, + parentSuspense, + ) + // in case props have changed + patch( + instance.vnode, + vnode, + container, + anchor, + instance, + parentSuspense, + namespace, + vnode.slotScopeIds, + optimized, + ) + queuePostRenderEffect(() => { + instance.isDeactivated = false + if (instance.a) { + invokeArrayFns(instance.a) + } + const vnodeHook = vnode.props && vnode.props.onVnodeMounted + if (vnodeHook) { + invokeVNodeHook(vnodeHook, instance.parent, vnode) + } + }, parentSuspense) + + if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { + // Update components tree + devtoolsComponentAdded(instance) + } +} + +/** + * shared between runtime-core and runtime-vapor + */ +export function deactivate( + vnode: VNode, + container: RendererElement, + { m: move }: RendererInternals, + parentComponent: ComponentInternalInstance | null, + parentSuspense: SuspenseBoundary | null, +): void { + const instance = vnode.component! + invalidateMount(instance.m) + invalidateMount(instance.a) + + move(vnode, container, null, MoveType.LEAVE, parentComponent, parentSuspense) + queuePostRenderEffect(() => { + if (instance.da) { + invokeArrayFns(instance.da) + } + const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted + if (vnodeHook) { + invokeVNodeHook(vnodeHook, instance.parent, vnode) + } + instance.isDeactivated = true + }, parentSuspense) + + if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) { + // Update components tree + devtoolsComponentAdded(instance) + } ++ ++ ++ // for e2e test ++ if (__DEV__ && __BROWSER__) { ++ ;(instance as any).__keepAliveStorageContainer = container ++ } +}