1
1
import { patch } from 'web/runtime/patch'
2
- import VNode from 'core/vdom/vnode'
2
+ import VNode , { createEmptyVNode } from 'core/vdom/vnode'
3
3
4
4
function prop ( name ) {
5
5
return obj => { return obj [ name ] }
@@ -445,7 +445,7 @@ describe('vdom patch: children', () => {
445
445
expect ( child2 . className ) . toBe ( '' )
446
446
} )
447
447
448
- it ( 'should handle static vnodes properly' , function ( ) {
448
+ it ( 'should handle static vnodes properly' , ( ) => {
449
449
function makeNode ( text ) {
450
450
return new VNode ( 'div' , undefined , [
451
451
new VNode ( undefined , undefined , undefined , text )
@@ -466,7 +466,7 @@ describe('vdom patch: children', () => {
466
466
expect ( elm . textContent ) . toBe ( 'ABC' )
467
467
} )
468
468
469
- it ( 'should handle static vnodes inside ' , function ( ) {
469
+ it ( 'should handle static vnodes inside ' , ( ) => {
470
470
function makeNode ( text ) {
471
471
return new VNode ( 'div' , undefined , [
472
472
new VNode ( undefined , undefined , undefined , text )
@@ -486,4 +486,25 @@ describe('vdom patch: children', () => {
486
486
elm = patch ( vnode2 , vnode3 )
487
487
expect ( elm . textContent ) . toBe ( 'ABC' )
488
488
} )
489
+
490
+ // #6502
491
+ it ( 'should not de-opt when both head and tail are changed' , ( ) => {
492
+ const vnode1 = new VNode ( 'div' , { } , [
493
+ createEmptyVNode ( ) ,
494
+ new VNode ( 'div' ) ,
495
+ createEmptyVNode ( )
496
+ ] )
497
+ const vnode2 = new VNode ( 'div' , { } , [
498
+ new VNode ( 'p' ) ,
499
+ new VNode ( 'div' ) ,
500
+ new VNode ( 'p' )
501
+ ] )
502
+ let root = patch ( null , vnode1 )
503
+ const original = root . childNodes [ 1 ]
504
+
505
+ root = patch ( vnode1 , vnode2 )
506
+ const postPatch = root . childNodes [ 1 ]
507
+
508
+ expect ( postPatch ) . toBe ( original )
509
+ } )
489
510
} )
0 commit comments