@@ -10,8 +10,7 @@ import {
10
10
isSameVNodeType ,
11
11
Static ,
12
12
VNodeNormalizedRef ,
13
- VNodeHook ,
14
- isVNode
13
+ VNodeHook
15
14
} from './vnode'
16
15
import {
17
16
ComponentInternalInstance ,
@@ -639,31 +638,7 @@ function baseCreateRenderer(
639
638
optimized
640
639
)
641
640
} else {
642
- if (
643
- __DEV__ &&
644
- isHmrUpdating &&
645
- hostCloneNode !== undefined &&
646
- n2 . patchFlag === PatchFlags . HOISTED
647
- ) {
648
- // https://github.com/vitejs/vite/issues/514
649
- // reused hoisted trees are inserted with cloneNode
650
- // which makes them not patch-able. In production hoisted trees are
651
- // never patched (because they are not collected as dynamic nodes), but
652
- // they can be udpated during HMR. In this case just mount it as new
653
- // and remove the stale DOM tree.
654
- mountElement (
655
- n2 ,
656
- container ,
657
- n1 . el ,
658
- parentComponent ,
659
- parentSuspense ,
660
- isSVG ,
661
- optimized
662
- )
663
- hostRemove ( n1 . el ! )
664
- } else {
665
- patchElement ( n1 , n2 , parentComponent , parentSuspense , isSVG , optimized )
666
- }
641
+ patchElement ( n1 , n2 , parentComponent , parentSuspense , isSVG , optimized )
667
642
}
668
643
}
669
644
@@ -688,13 +663,15 @@ function baseCreateRenderer(
688
663
dirs
689
664
} = vnode
690
665
if (
666
+ ! __DEV__ &&
691
667
vnode . el &&
692
668
hostCloneNode !== undefined &&
693
669
patchFlag === PatchFlags . HOISTED
694
670
) {
695
671
// If a vnode has non-null el, it means it's being reused.
696
672
// Only static vnodes can be reused, so its mounted DOM nodes should be
697
673
// exactly the same, and we can simply do a clone here.
674
+ // only do this in production since cloned trees cannot be HMR updated.
698
675
el = vnode . el = hostCloneNode ( vnode . el )
699
676
} else {
700
677
el = vnode . el = hostCreateElement (
@@ -2107,14 +2084,11 @@ function baseCreateRenderer(
2107
2084
const ch2 = n2 . children
2108
2085
if ( isArray ( ch1 ) && isArray ( ch2 ) ) {
2109
2086
for ( let i = 0 ; i < ch1 . length ; i ++ ) {
2110
- const c1 = ch1 [ i ]
2111
- const c2 = ch2 [ i ]
2112
- if (
2113
- isVNode ( c1 ) &&
2114
- isVNode ( c2 ) &&
2115
- c2 . shapeFlag & ShapeFlags . ELEMENT &&
2116
- ! c2 . dynamicChildren
2117
- ) {
2087
+ // this is only called in the optimized path so array children are
2088
+ // guaranteed to be vnodes
2089
+ const c1 = ch1 [ i ] as VNode
2090
+ const c2 = ( ch2 [ i ] = cloneIfMounted ( ch2 [ i ] as VNode ) )
2091
+ if ( c2 . shapeFlag & ShapeFlags . ELEMENT && ! c2 . dynamicChildren ) {
2118
2092
if ( c2 . patchFlag <= 0 ) {
2119
2093
c2 . el = c1 . el
2120
2094
}
0 commit comments