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 () {
3636
3737function flushBatcherQueue ( ) {
3838 runBatcherQueue ( queue )
39- queue . length = 0
4039 runBatcherQueue ( userQueue )
41- // user watchers triggered more internal watchers
40+ // user watchers triggered more watchers,
41+ // keep flushing until it depletes
4242 if ( queue . length ) {
43- runBatcherQueue ( queue )
43+ return flushBatcherQueue ( )
4444 }
4545 // dev tool hook
4646 /* istanbul ignore if */
@@ -77,6 +77,7 @@ function runBatcherQueue (queue) {
7777 }
7878 }
7979 }
80+ queue . length = 0
8081}
8182
8283/**
Original file line number Diff line number Diff line change @@ -546,4 +546,35 @@ describe('Misc', function () {
546546 } )
547547 expect ( vm . $el . textContent ) . toBe ( '135' )
548548 } )
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+ } )
549580} )
You can’t perform that action at this time.
0 commit comments