@@ -459,7 +459,7 @@ export function cloneVNode<T, U>(
459459) : VNode < T , U > {
460460 // This is intentionally NOT using spread or extend to avoid the runtime
461461 // key enumeration cost.
462- const { props, ref, patchFlag } = vnode
462+ const { props, ref, patchFlag, children } = vnode
463463 const mergedProps = extraProps ? mergeProps ( props || { } , extraProps ) : props
464464 return {
465465 __v_isVNode : true ,
@@ -479,7 +479,10 @@ export function cloneVNode<T, U>(
479479 : normalizeRef ( extraProps )
480480 : ref ,
481481 scopeId : vnode . scopeId ,
482- children : vnode . children ,
482+ children :
483+ __DEV__ && patchFlag === PatchFlags . HOISTED && isArray ( children )
484+ ? ( children as VNode [ ] ) . map ( deepCloneVNode )
485+ : children ,
483486 target : vnode . target ,
484487 targetAnchor : vnode . targetAnchor ,
485488 staticCount : vnode . staticCount ,
@@ -513,6 +516,18 @@ export function cloneVNode<T, U>(
513516 }
514517}
515518
519+ /**
520+ * Dev only, for HMR of hoisted vnodes reused in v-for
521+ * https://github.com/vitejs/vite/issues/2022
522+ */
523+ function deepCloneVNode ( vnode : VNode ) : VNode {
524+ const cloned = cloneVNode ( vnode )
525+ if ( isArray ( vnode . children ) ) {
526+ cloned . children = ( vnode . children as VNode [ ] ) . map ( deepCloneVNode )
527+ }
528+ return cloned
529+ }
530+
516531/**
517532 * @private
518533 */
0 commit comments