@@ -158,9 +158,7 @@ export default class Backburner {
158158
159159 this . _platform = platform ;
160160
161- this . _boundRunExpiredTimers = ( ) => {
162- this . _runExpiredTimers ( ) ;
163- } ;
161+ this . _boundRunExpiredTimers = this . _runExpiredTimers . bind ( this ) ;
164162
165163 this . _boundAutorunEnd = ( ) => {
166164 autorunsCompletedCount ++ ;
@@ -586,9 +584,10 @@ export default class Backburner {
586584
587585 public cancel ( timer ?) {
588586 cancelCount ++ ;
589- if ( ! timer ) { return false ; }
587+
588+ if ( timer === undefined || timer === null ) { return false ; }
589+
590590 let timerType = typeof timer ;
591-
592591 if ( timerType === 'number' ) { // we're cancelling a throttle or debounce
593592 return this . _cancelItem ( timer , this . _throttlers ) || this . _cancelItem ( timer , this . _debouncees ) ;
594593 } else if ( timerType === 'string' ) { // we're cancelling a setTimeout
@@ -653,18 +652,16 @@ export default class Backburner {
653652 if ( this . _timers . length === 0 ) {
654653 this . _timers . push ( executeAt , id , target , method , args , stack ) ;
655654 this . _installTimerTimeout ( ) ;
656- return id ;
657- }
658-
659- // find position to insert
660- let i = searchTimer ( executeAt , this . _timers ) ;
661- this . _timers . splice ( i , 0 , executeAt , id , target , method , args , stack ) ;
655+ } else {
656+ // find position to insert
657+ let i = searchTimer ( executeAt , this . _timers ) ;
658+ this . _timers . splice ( i , 0 , executeAt , id , target , method , args , stack ) ;
662659
663- // we should be the new earliest timer if i == 0
664- if ( i === 0 ) {
665- this . _reinstallTimerTimeout ( ) ;
660+ // we should be the new earliest timer if i == 0
661+ if ( i === 0 ) {
662+ this . _reinstallTimerTimeout ( ) ;
663+ }
666664 }
667-
668665 return id ;
669666 }
670667
@@ -716,10 +713,11 @@ export default class Backburner {
716713
717714 private _runExpiredTimers ( ) {
718715 this . _timerTimeoutId = null ;
719- if ( this . _timers . length === 0 ) { return ; }
720- this . begin ( ) ;
721- this . _scheduleExpiredTimers ( ) ;
722- this . end ( ) ;
716+ if ( this . _timers . length > 0 ) {
717+ this . begin ( ) ;
718+ this . _scheduleExpiredTimers ( ) ;
719+ this . end ( ) ;
720+ }
723721 }
724722
725723 private _scheduleExpiredTimers ( ) {
@@ -731,15 +729,13 @@ export default class Backburner {
731729
732730 for ( ; i < l ; i += 6 ) {
733731 let executeAt = timers [ i ] ;
734- if ( executeAt <= n ) {
735- let target = timers [ i + 2 ] ;
736- let method = timers [ i + 3 ] ;
737- let args = timers [ i + 4 ] ;
738- let stack = timers [ i + 5 ] ;
739- this . currentInstance ! . schedule ( defaultQueue , target , method , args , false , stack ) ;
740- } else {
741- break ;
742- }
732+ if ( executeAt > n ) { break ; }
733+
734+ let target = timers [ i + 2 ] ;
735+ let method = timers [ i + 3 ] ;
736+ let args = timers [ i + 4 ] ;
737+ let stack = timers [ i + 5 ] ;
738+ this . currentInstance ! . schedule ( defaultQueue , target , method , args , false , stack ) ;
743739 }
744740
745741 timers . splice ( 0 , i ) ;
0 commit comments