File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,11 @@ function resetBatcherState () {
36
36
37
37
function flushBatcherQueue ( ) {
38
38
runBatcherQueue ( queue )
39
- queue . length = 0
40
39
runBatcherQueue ( userQueue )
41
- // user watchers triggered more internal watchers
40
+ // user watchers triggered more watchers,
41
+ // keep flushing until it depletes
42
42
if ( queue . length ) {
43
- runBatcherQueue ( queue )
43
+ return flushBatcherQueue ( )
44
44
}
45
45
// dev tool hook
46
46
/* istanbul ignore if */
@@ -77,6 +77,7 @@ function runBatcherQueue (queue) {
77
77
}
78
78
}
79
79
}
80
+ queue . length = 0
80
81
}
81
82
82
83
/**
Original file line number Diff line number Diff line change @@ -546,4 +546,35 @@ describe('Misc', function () {
546
546
} )
547
547
expect ( vm . $el . textContent ) . toBe ( '135' )
548
548
} )
549
+
550
+ // #2821
551
+ it ( 'batcher should keep flushing until all queues are depleted' , done => {
552
+ var spy = jasmine . createSpy ( )
553
+ var vm = new Vue ( {
554
+ el : document . createElement ( 'div' ) ,
555
+ template : '<test :prop="model"></test>' ,
556
+ data : {
557
+ model : 0 ,
558
+ count : 0
559
+ } ,
560
+ watch : {
561
+ count : function ( ) {
562
+ this . model ++
563
+ }
564
+ } ,
565
+ components : {
566
+ test : {
567
+ props : [ 'prop' ] ,
568
+ watch : {
569
+ prop : spy
570
+ }
571
+ }
572
+ }
573
+ } )
574
+ vm . count ++
575
+ Vue . nextTick ( function ( ) {
576
+ expect ( spy ) . toHaveBeenCalled ( )
577
+ done ( )
578
+ } )
579
+ } )
549
580
} )
You can’t perform that action at this time.
0 commit comments