@@ -227,52 +227,24 @@ function constructNewChildrenArray(newParentVNode, renderResult, oldChildren) {
227
227
childVNode = newParentVNode . _children [ i ] = childVNode ;
228
228
}
229
229
230
- const skewedIndex = i + skew ;
231
-
232
230
// Handle unmounting null placeholders, i.e. VNode => null in unkeyed children
233
231
if ( childVNode == null ) {
234
- oldVNode = oldChildren [ skewedIndex ] ;
235
- if (
236
- oldVNode &&
237
- oldVNode . key == null &&
238
- oldVNode . _dom &&
239
- ( oldVNode . _flags & MATCHED ) === 0
240
- ) {
241
- if ( oldVNode . _dom == newParentVNode . _nextDom ) {
242
- newParentVNode . _nextDom = getDomSibling ( oldVNode ) ;
243
- }
244
-
245
- unmount ( oldVNode , oldVNode , false ) ;
246
-
247
- // Explicitly nullify this position in oldChildren instead of just
248
- // setting `_match=true` to prevent other routines (e.g.
249
- // `findMatchingIndex` or `getDomSibling`) from thinking VNodes or DOM
250
- // nodes in this position are still available to be used in diffing when
251
- // they have actually already been unmounted. For example, by only
252
- // setting `_match=true` here, the unmounting loop later would attempt
253
- // to unmount this VNode again seeing `_match==true`. Further,
254
- // getDomSibling doesn't know about _match and so would incorrectly
255
- // assume DOM nodes in this subtree are mounted and usable.
256
- oldChildren [ skewedIndex ] = null ;
257
- remainingOldChildren -- ;
258
- }
259
232
continue ;
260
233
}
261
234
235
+ const skewedIndex = i + skew ;
262
236
childVNode . _parent = newParentVNode ;
263
237
childVNode . _depth = newParentVNode . _depth + 1 ;
264
238
265
- const matchingIndex = findMatchingIndex (
239
+ // Temporarily store the matchingIndex on the _index property so we can pull
240
+ // out the oldVNode in diffChildren. We'll override this to the VNode's
241
+ // final index after using this property to get the oldVNode
242
+ const matchingIndex = ( childVNode . _index = findMatchingIndex (
266
243
childVNode ,
267
244
oldChildren ,
268
245
skewedIndex ,
269
246
remainingOldChildren
270
- ) ;
271
-
272
- // Temporarily store the matchingIndex on the _index property so we can pull
273
- // out the oldVNode in diffChildren. We'll override this to the VNode's
274
- // final index after using this property to get the oldVNode
275
- childVNode . _index = matchingIndex ;
247
+ ) ) ;
276
248
277
249
oldVNode = null ;
278
250
if ( matchingIndex !== - 1 ) {
@@ -318,16 +290,18 @@ function constructNewChildrenArray(newParentVNode, renderResult, oldChildren) {
318
290
skew -- ;
319
291
} else if ( matchingIndex == skewedIndex + 1 ) {
320
292
skew ++ ;
321
- } else if ( matchingIndex > skewedIndex ) {
322
- skew -- ;
323
293
} else {
324
- skew ++ ;
325
- }
294
+ if ( matchingIndex > skewedIndex ) {
295
+ skew -- ;
296
+ } else {
297
+ skew ++ ;
298
+ }
326
299
327
- // Move this VNode's DOM if the original index (matchingIndex) doesn't
328
- // match the new skew index (i + new skew)
329
- if ( matchingIndex !== i + skew ) {
330
- childVNode . _flags |= INSERT_VNODE ;
300
+ // Move this VNode's DOM if the original index (matchingIndex) doesn't
301
+ // match the new skew index (i + new skew)
302
+ if ( matchingIndex !== i + skew ) {
303
+ childVNode . _flags |= INSERT_VNODE ;
304
+ }
331
305
}
332
306
}
333
307
}
0 commit comments