MCPcopy
hub / github.com/vuejs/core / cacheSubtree

Function cacheSubtree

packages/runtime-core/src/components/KeepAlive.ts:244–257  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

242 // cache sub tree after render
243 let pendingCacheKey: CacheKey | null = null
244 const cacheSubtree = () => {
245 // fix #1621, the pendingCacheKey could be 0
246 if (pendingCacheKey != null) {
247 // if KeepAlive child is a Suspense, it needs to be cached after Suspense resolves
248 // avoid caching vnode that not been mounted
249 if (isSuspense(instance.subTree.type)) {
250 queuePostRenderEffect(() => {
251 cache.set(pendingCacheKey!, getInnerChild(instance.subTree))
252 }, instance.subTree.suspense)
253 } else {
254 cache.set(pendingCacheKey, getInnerChild(instance.subTree))
255 }
256 }
257 }
258 onMounted(cacheSubtree)
259 onUpdated(cacheSubtree)
260

Callers

nothing calls this directly

Calls 3

isSuspenseFunction · 0.90
getInnerChildFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected