@@ -130,12 +130,9 @@ function $RootScopeProvider(){
130130 this . $$childHead = this . $$childTail = null ;
131131 this [ 'this' ] = this . $root = this ;
132132 this . $$destroyed = false ;
133- this . $$asyncQueue = [ ] ;
134- this . $$postDigestQueue = [ ] ;
135133 this . $$listeners = { } ;
136134 this . $$listenerCount = { } ;
137135 this . $$isolateBindings = null ;
138- this . $$applyAsyncQueue = [ ] ;
139136 }
140137
141138 /**
@@ -193,9 +190,6 @@ function $RootScopeProvider(){
193190 if ( isolate ) {
194191 child = new Scope ( ) ;
195192 child . $root = this . $root ;
196- // ensure that there is just one async queue per $rootScope and its children
197- child . $$asyncQueue = this . $$asyncQueue ;
198- child . $$postDigestQueue = this . $$postDigestQueue ;
199193 } else {
200194 // Only create a child scope class if somebody asks for one,
201195 // but cache it to allow the VM to optimize lookups.
@@ -695,8 +689,6 @@ function $RootScopeProvider(){
695689 $digest : function ( ) {
696690 var watch , value , last ,
697691 watchers ,
698- asyncQueue = this . $$asyncQueue ,
699- postDigestQueue = this . $$postDigestQueue ,
700692 length ,
701693 dirty , ttl = TTL ,
702694 next , current , target = this ,
@@ -861,6 +853,10 @@ function $RootScopeProvider(){
861853 if ( this . $$prevSibling ) this . $$prevSibling . $$nextSibling = this . $$nextSibling ;
862854 if ( this . $$nextSibling ) this . $$nextSibling . $$prevSibling = this . $$prevSibling ;
863855
856+ // Disable listeners, watchers and apply/digest methods
857+ this . $destroy = this . $digest = this . $apply = this . $evalAsync = this . $applyAsync = noop ;
858+ this . $on = this . $watch = this . $watchGroup = function ( ) { return noop ; } ;
859+ this . $$listeners = { } ;
864860
865861 // All of the code below is bogus code that works around V8's memory leak via optimized code
866862 // and inline caches.
@@ -871,15 +867,7 @@ function $RootScopeProvider(){
871867 // - https://github.com/angular/angular.js/issues/1313#issuecomment-10378451
872868
873869 this . $parent = this . $$nextSibling = this . $$prevSibling = this . $$childHead =
874- this . $$childTail = this . $root = null ;
875-
876- // don't reset these to null in case some async task tries to register a listener/watch/task
877- this . $$listeners = { } ;
878- this . $$watchers = this . $$asyncQueue = this . $$postDigestQueue = [ ] ;
879-
880- // prevent NPEs since these methods have references to properties we nulled out
881- this . $destroy = this . $digest = this . $apply = noop ;
882- this . $on = this . $watch = this . $watchGroup = function ( ) { return noop ; } ;
870+ this . $$childTail = this . $root = this . $$watchers = null ;
883871 } ,
884872
885873 /**
@@ -946,19 +934,19 @@ function $RootScopeProvider(){
946934 $evalAsync : function ( expr ) {
947935 // if we are outside of an $digest loop and this is the first time we are scheduling async
948936 // task also schedule async auto-flush
949- if ( ! $rootScope . $$phase && ! $rootScope . $$ asyncQueue. length ) {
937+ if ( ! $rootScope . $$phase && ! asyncQueue . length ) {
950938 $browser . defer ( function ( ) {
951- if ( $rootScope . $$ asyncQueue. length ) {
939+ if ( asyncQueue . length ) {
952940 $rootScope . $digest ( ) ;
953941 }
954942 } ) ;
955943 }
956944
957- this . $$ asyncQueue. push ( { scope : this , expression : expr } ) ;
945+ asyncQueue . push ( { scope : this , expression : expr } ) ;
958946 } ,
959947
960948 $$postDigest : function ( fn ) {
961- this . $$ postDigestQueue. push ( fn ) ;
949+ postDigestQueue . push ( fn ) ;
962950 } ,
963951
964952 /**
@@ -1042,7 +1030,7 @@ function $RootScopeProvider(){
10421030 */
10431031 $applyAsync : function ( expr ) {
10441032 var scope = this ;
1045- expr && $rootScope . $$ applyAsyncQueue. push ( $applyAsyncExpression ) ;
1033+ expr && applyAsyncQueue . push ( $applyAsyncExpression ) ;
10461034 scheduleApplyAsync ( ) ;
10471035
10481036 function $applyAsyncExpression ( ) {
@@ -1251,6 +1239,11 @@ function $RootScopeProvider(){
12511239
12521240 var $rootScope = new Scope ( ) ;
12531241
1242+ //The internal queues. Expose them on the $rootScope for debugging/testing purposes.
1243+ var asyncQueue = $rootScope . $$asyncQueue = [ ] ;
1244+ var postDigestQueue = $rootScope . $$postDigestQueue = [ ] ;
1245+ var applyAsyncQueue = $rootScope . $$applyAsyncQueue = [ ] ;
1246+
12541247 return $rootScope ;
12551248
12561249
@@ -1284,10 +1277,9 @@ function $RootScopeProvider(){
12841277 function initWatchVal ( ) { }
12851278
12861279 function flushApplyAsync ( ) {
1287- var queue = $rootScope . $$applyAsyncQueue ;
1288- while ( queue . length ) {
1280+ while ( applyAsyncQueue . length ) {
12891281 try {
1290- queue . shift ( ) ( ) ;
1282+ applyAsyncQueue . shift ( ) ( ) ;
12911283 } catch ( e ) {
12921284 $exceptionHandler ( e ) ;
12931285 }
0 commit comments