| 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, |