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

Function getCacheExpression

packages/compiler-core/src/transforms/cacheStatic.ts:217–230  ·  view source on GitHub ↗
(value: JSChildNode)

Source from the content-addressed store, hash-verified

215 }
216
217 function getCacheExpression(value: JSChildNode): CacheExpression {
218 const exp = context.cache(value)
219 // #6978, #7138, #7114
220 // a cached children array inside v-for can caused HMR errors since
221 // it might be mutated when mounting the first item
222 // #13221
223 // fix memory leak in cached array:
224 // cached vnodes get replaced by cloned ones during mountChildren,
225 // which bind DOM elements. These DOM references persist after unmount,
226 // preventing garbage collection. Array spread avoids mutating cached
227 // array, preventing memory leaks.
228 exp.needArraySpread = true
229 return exp
230 }
231
232 function getSlotNode(
233 node: VNodeCall,

Callers 1

walkFunction · 0.85

Calls 1

cacheMethod · 0.80

Tested by

no test coverage detected