File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -1079,7 +1079,8 @@ function baseCreateRenderer(
10791079 dynamicChildren &&
10801080 // #2715 the previous fragment could've been a BAILed one as a result
10811081 // of renderSlot() with no valid children
1082- n1 . dynamicChildren
1082+ n1 . dynamicChildren &&
1083+ n1 . dynamicChildren . length === dynamicChildren . length
10831084 ) {
10841085 // a stable fragment (template root or <template v-for>) doesn't need to
10851086 // patch children order, but it may contain dynamicChildren.
Original file line number Diff line number Diff line change @@ -311,4 +311,34 @@ describe('compiler + runtime integration', () => {
311311 app . mount ( root )
312312 expect ( root . innerHTML ) . toBe ( '<div>60000000100000111</div>' )
313313 } )
314+
315+ test ( 'should correctly update when reactive state and normal array are modified' , async ( ) => {
316+ const count = ref ( 0 )
317+ const foo : any [ ] = [ ]
318+ function updateFoo ( ) {
319+ for ( let n = 0 ; n < 3 ; n ++ ) {
320+ foo [ n ] = n + 1 + '_foo'
321+ }
322+ }
323+ const app = createApp ( {
324+ setup ( ) {
325+ return {
326+ count,
327+ foo,
328+ }
329+ } ,
330+ template : `
331+ <div>{{count}}</div>
332+ <div v-for='item in foo'>{{ item }}</div>` ,
333+ } )
334+ const root = document . createElement ( 'div' )
335+ app . mount ( root )
336+ expect ( root . innerHTML ) . toBe ( '<div>0</div>' )
337+ updateFoo ( )
338+ count . value ++
339+ await nextTick ( )
340+ expect ( root . innerHTML ) . toBe (
341+ '<div>1</div><div>1_foo</div><div>2_foo</div><div>3_foo</div>' ,
342+ )
343+ } )
314344} )
You can’t perform that action at this time.
0 commit comments