mirror of https://github.com/vuejs/core.git
chore: add comments
This commit is contained in:
parent
87d1e5f028
commit
639fc0baf3
|
@ -219,6 +219,12 @@ function walk(
|
|||
// #6978, #7138, #7114
|
||||
// a cached children array inside v-for can caused HMR errors since
|
||||
// it might be mutated when mounting the first item
|
||||
// #13221
|
||||
// fix memory leak in cached array:
|
||||
// cached vnodes get replaced by cloned ones during mountChildren,
|
||||
// which bind DOM elements. These DOM references persist after unmount,
|
||||
// preventing garbage collection. Array spread avoids mutating cached
|
||||
// array, preventing memory leaks.
|
||||
exp.needArraySpread = true
|
||||
return exp
|
||||
}
|
||||
|
|
|
@ -680,9 +680,7 @@ export function cloneVNode<T, U>(
|
|||
scopeId: vnode.scopeId,
|
||||
slotScopeIds: vnode.slotScopeIds,
|
||||
children:
|
||||
// if vnode is cached, deep clone it's children to prevent cached children
|
||||
// from retaining detached DOM nodes
|
||||
patchFlag === PatchFlags.CACHED && isArray(children)
|
||||
__DEV__ && patchFlag === PatchFlags.CACHED && isArray(children)
|
||||
? (children as VNode[]).map(deepCloneVNode)
|
||||
: children,
|
||||
target: vnode.target,
|
||||
|
@ -740,7 +738,7 @@ export function cloneVNode<T, U>(
|
|||
}
|
||||
|
||||
/**
|
||||
* for HMR of hoisted vnodes reused in v-for
|
||||
* Dev only, for HMR of hoisted vnodes reused in v-for
|
||||
* https://github.com/vitejs/vite/issues/2022
|
||||
*/
|
||||
function deepCloneVNode(vnode: VNode): VNode {
|
||||
|
|
Loading…
Reference in New Issue