From: daiwei Date: Tue, 6 Jan 2026 03:28:25 +0000 (+0800) Subject: refactor: remove `cacheFragment` function and rename `instance` to `block` in `innerC... X-Git-Tag: v3.6.0-beta.3~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cfd45ce79352362f055cf782dc6f6af77cf1020;p=thirdparty%2Fvuejs%2Fcore.git refactor: remove `cacheFragment` function and rename `instance` to `block` in `innerCacheBlock` --- diff --git a/packages/runtime-vapor/src/components/KeepAlive.ts b/packages/runtime-vapor/src/components/KeepAlive.ts index 66e1d7a3ae..a2a3eb0719 100644 --- a/packages/runtime-vapor/src/components/KeepAlive.ts +++ b/packages/runtime-vapor/src/components/KeepAlive.ts @@ -102,7 +102,7 @@ const KeepAliveImpl: ObjectVaporComponent = defineVaporComponent({ const innerCacheBlock = ( key: CacheKey, - instance: VaporComponentInstance | VaporFragment, + block: VaporComponentInstance | VaporFragment, ) => { const { max } = props @@ -118,8 +118,8 @@ const KeepAliveImpl: ObjectVaporComponent = defineVaporComponent({ } } - cache.set(key, instance) - current = instance + cache.set(key, block) + current = block } const cacheBlock = () => { @@ -151,21 +151,6 @@ const KeepAliveImpl: ObjectVaporComponent = defineVaporComponent({ return true } - const cacheFragment = (fragment: DynamicFragment) => { - const [innerBlock, interop] = getInnerBlock(fragment.nodes) - if (!innerBlock || !shouldCache(innerBlock, props, interop)) return - - let key: CacheKey - if (interop) { - innerBlock.vnode!.shapeFlag! |= ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE - key = innerBlock.vnode!.type - } else { - innerBlock.shapeFlag! |= ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE - key = innerBlock.type - } - innerCacheBlock(key, innerBlock) - } - const pruneCache = (filter: (name: string) => boolean) => { cache.forEach((cached, key) => { const instance = getInstanceFromCache(cached) @@ -255,7 +240,7 @@ const KeepAliveImpl: ObjectVaporComponent = defineVaporComponent({ }, ) ;(frag.onBeforeMount || (frag.onBeforeMount = [])).push(() => - cacheFragment(frag), + processFragment(frag), ) frag.getScope = key => { const scope = keptAliveScopes.get(key)