@@ -130,12 +130,9 @@ function $RootScopeProvider(){
130
130
this . $$childHead = this . $$childTail = null ;
131
131
this [ 'this' ] = this . $root = this ;
132
132
this . $$destroyed = false ;
133
- this . $$asyncQueue = [ ] ;
134
- this . $$postDigestQueue = [ ] ;
135
133
this . $$listeners = { } ;
136
134
this . $$listenerCount = { } ;
137
135
this . $$isolateBindings = null ;
138
- this . $$applyAsyncQueue = [ ] ;
139
136
}
140
137
141
138
/**
@@ -193,9 +190,6 @@ function $RootScopeProvider(){
193
190
if ( isolate ) {
194
191
child = new Scope ( ) ;
195
192
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 ;
199
193
} else {
200
194
// Only create a child scope class if somebody asks for one,
201
195
// but cache it to allow the VM to optimize lookups.
@@ -695,8 +689,6 @@ function $RootScopeProvider(){
695
689
$digest : function ( ) {
696
690
var watch , value , last ,
697
691
watchers ,
698
- asyncQueue = this . $$asyncQueue ,
699
- postDigestQueue = this . $$postDigestQueue ,
700
692
length ,
701
693
dirty , ttl = TTL ,
702
694
next , current , target = this ,
@@ -861,6 +853,10 @@ function $RootScopeProvider(){
861
853
if ( this . $$prevSibling ) this . $$prevSibling . $$nextSibling = this . $$nextSibling ;
862
854
if ( this . $$nextSibling ) this . $$nextSibling . $$prevSibling = this . $$prevSibling ;
863
855
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 = { } ;
864
860
865
861
// All of the code below is bogus code that works around V8's memory leak via optimized code
866
862
// and inline caches.
@@ -871,15 +867,7 @@ function $RootScopeProvider(){
871
867
// - https://github.com/angular/angular.js/issues/1313#issuecomment-10378451
872
868
873
869
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 ;
883
871
} ,
884
872
885
873
/**
@@ -946,19 +934,19 @@ function $RootScopeProvider(){
946
934
$evalAsync : function ( expr ) {
947
935
// if we are outside of an $digest loop and this is the first time we are scheduling async
948
936
// task also schedule async auto-flush
949
- if ( ! $rootScope . $$phase && ! $rootScope . $$ asyncQueue. length ) {
937
+ if ( ! $rootScope . $$phase && ! asyncQueue . length ) {
950
938
$browser . defer ( function ( ) {
951
- if ( $rootScope . $$ asyncQueue. length ) {
939
+ if ( asyncQueue . length ) {
952
940
$rootScope . $digest ( ) ;
953
941
}
954
942
} ) ;
955
943
}
956
944
957
- this . $$ asyncQueue. push ( { scope : this , expression : expr } ) ;
945
+ asyncQueue . push ( { scope : this , expression : expr } ) ;
958
946
} ,
959
947
960
948
$$postDigest : function ( fn ) {
961
- this . $$ postDigestQueue. push ( fn ) ;
949
+ postDigestQueue . push ( fn ) ;
962
950
} ,
963
951
964
952
/**
@@ -1042,7 +1030,7 @@ function $RootScopeProvider(){
1042
1030
*/
1043
1031
$applyAsync : function ( expr ) {
1044
1032
var scope = this ;
1045
- expr && $rootScope . $$ applyAsyncQueue. push ( $applyAsyncExpression ) ;
1033
+ expr && applyAsyncQueue . push ( $applyAsyncExpression ) ;
1046
1034
scheduleApplyAsync ( ) ;
1047
1035
1048
1036
function $applyAsyncExpression ( ) {
@@ -1251,6 +1239,11 @@ function $RootScopeProvider(){
1251
1239
1252
1240
var $rootScope = new Scope ( ) ;
1253
1241
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
+
1254
1247
return $rootScope ;
1255
1248
1256
1249
@@ -1284,10 +1277,9 @@ function $RootScopeProvider(){
1284
1277
function initWatchVal ( ) { }
1285
1278
1286
1279
function flushApplyAsync ( ) {
1287
- var queue = $rootScope . $$applyAsyncQueue ;
1288
- while ( queue . length ) {
1280
+ while ( applyAsyncQueue . length ) {
1289
1281
try {
1290
- queue . shift ( ) ( ) ;
1282
+ applyAsyncQueue . shift ( ) ( ) ;
1291
1283
} catch ( e ) {
1292
1284
$exceptionHandler ( e ) ;
1293
1285
}
0 commit comments