3
3
Fragment ,
4
4
Comment ,
5
5
Portal ,
6
+ cloneIfMounted ,
6
7
normalizeVNode ,
7
8
VNode ,
8
9
VNodeChildren ,
@@ -438,9 +439,9 @@ export function createRenderer<
438
439
start : number = 0
439
440
) {
440
441
for ( let i = start ; i < children . length ; i ++ ) {
441
- const child = optimized
442
- ? ( children [ i ] as HostVNode )
443
- : ( children [ i ] = normalizeVNode ( children [ i ] ) )
442
+ const child = ( children [ i ] = optimized
443
+ ? cloneIfMounted ( children [ i ] as HostVNode )
444
+ : normalizeVNode ( children [ i ] ) )
444
445
patch (
445
446
null ,
446
447
child ,
@@ -1198,9 +1199,9 @@ export function createRenderer<
1198
1199
const commonLength = Math . min ( oldLength , newLength )
1199
1200
let i
1200
1201
for ( i = 0 ; i < commonLength ; i ++ ) {
1201
- const nextChild = optimized
1202
- ? ( c2 [ i ] as HostVNode )
1203
- : ( c2 [ i ] = normalizeVNode ( c2 [ i ] ) )
1202
+ const nextChild = ( c2 [ i ] = optimized
1203
+ ? cloneIfMounted ( c2 [ i ] as HostVNode )
1204
+ : normalizeVNode ( c2 [ i ] ) )
1204
1205
patch (
1205
1206
c1 [ i ] ,
1206
1207
nextChild ,
@@ -1251,9 +1252,9 @@ export function createRenderer<
1251
1252
// (a b) d e
1252
1253
while ( i <= e1 && i <= e2 ) {
1253
1254
const n1 = c1 [ i ]
1254
- const n2 = optimized
1255
- ? ( c2 [ i ] as HostVNode )
1256
- : ( c2 [ i ] = normalizeVNode ( c2 [ i ] ) )
1255
+ const n2 = ( c2 [ i ] = optimized
1256
+ ? cloneIfMounted ( c2 [ i ] as HostVNode )
1257
+ : normalizeVNode ( c2 [ i ] ) )
1257
1258
if ( isSameVNodeType ( n1 , n2 ) ) {
1258
1259
patch (
1259
1260
n1 ,
@@ -1276,9 +1277,9 @@ export function createRenderer<
1276
1277
// d e (b c)
1277
1278
while ( i <= e1 && i <= e2 ) {
1278
1279
const n1 = c1 [ e1 ]
1279
- const n2 = optimized
1280
- ? ( c2 [ e2 ] as HostVNode )
1281
- : ( c2 [ e2 ] = normalizeVNode ( c2 [ e2 ] ) )
1280
+ const n2 = ( c2 [ e2 ] = optimized
1281
+ ? cloneIfMounted ( c2 [ e2 ] as HostVNode )
1282
+ : normalizeVNode ( c2 [ e2 ] ) )
1282
1283
if ( isSameVNodeType ( n1 , n2 ) ) {
1283
1284
patch (
1284
1285
n1 ,
@@ -1309,10 +1310,13 @@ export function createRenderer<
1309
1310
const nextPos = e2 + 1
1310
1311
const anchor =
1311
1312
nextPos < l2 ? ( c2 [ nextPos ] as HostVNode ) . el : parentAnchor
1313
+ const n2 = ( c2 [ i ] = optimized
1314
+ ? cloneIfMounted ( c2 [ i ] as HostVNode )
1315
+ : normalizeVNode ( c2 [ i ] ) )
1312
1316
while ( i <= e2 ) {
1313
1317
patch (
1314
1318
null ,
1315
- optimized ? ( c2 [ i ] as HostVNode ) : ( c2 [ i ] = normalizeVNode ( c2 [ i ] ) ) ,
1319
+ n2 ,
1316
1320
container ,
1317
1321
anchor ,
1318
1322
parentComponent ,
@@ -1349,9 +1353,9 @@ export function createRenderer<
1349
1353
// 5.1 build key:index map for newChildren
1350
1354
const keyToNewIndexMap : Map < string | number , number > = new Map ( )
1351
1355
for ( i = s2 ; i <= e2 ; i ++ ) {
1352
- const nextChild = optimized
1353
- ? ( c2 [ i ] as HostVNode )
1354
- : ( c2 [ i ] = normalizeVNode ( c2 [ i ] ) )
1356
+ const nextChild = ( c2 [ i ] = optimized
1357
+ ? cloneIfMounted ( c2 [ i ] as HostVNode )
1358
+ : normalizeVNode ( c2 [ i ] ) )
1355
1359
if ( nextChild . key != null ) {
1356
1360
if ( __DEV__ && keyToNewIndexMap . has ( nextChild . key ) ) {
1357
1361
warn (
0 commit comments