@@ -459,7 +459,7 @@ export function cloneVNode<T, U>(
459
459
) : VNode < T , U > {
460
460
// This is intentionally NOT using spread or extend to avoid the runtime
461
461
// key enumeration cost.
462
- const { props, ref, patchFlag } = vnode
462
+ const { props, ref, patchFlag, children } = vnode
463
463
const mergedProps = extraProps ? mergeProps ( props || { } , extraProps ) : props
464
464
return {
465
465
__v_isVNode : true ,
@@ -479,7 +479,10 @@ export function cloneVNode<T, U>(
479
479
: normalizeRef ( extraProps )
480
480
: ref ,
481
481
scopeId : vnode . scopeId ,
482
- children : vnode . children ,
482
+ children :
483
+ __DEV__ && patchFlag === PatchFlags . HOISTED && isArray ( children )
484
+ ? ( children as VNode [ ] ) . map ( deepCloneVNode )
485
+ : children ,
483
486
target : vnode . target ,
484
487
targetAnchor : vnode . targetAnchor ,
485
488
staticCount : vnode . staticCount ,
@@ -513,6 +516,18 @@ export function cloneVNode<T, U>(
513
516
}
514
517
}
515
518
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
+
516
531
/**
517
532
* @private
518
533
*/
0 commit comments