]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
Merge branch 'vapor' into edison/feat/vaporKeepAlive
authoredison <daiwei521@126.com>
Mon, 14 Apr 2025 02:20:25 +0000 (10:20 +0800)
committerGitHub <noreply@github.com>
Mon, 14 Apr 2025 02:20:25 +0000 (10:20 +0800)
1  2 
packages/runtime-core/src/components/KeepAlive.ts
packages/runtime-core/src/index.ts

index 0a88a3303e668fd7b596a0a36e4956a3ece39a3c,d18d5a48b8f76b221039dbd0183edca8c552aa5c..6fc70e88c9a58ea8972b5aa59a06661ccc7afae9
@@@ -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
++  }
 +}
Simple merge