@@ -130,12 +130,9 @@ function $RootScopeProvider(){
130
130
this . $$childHead = this . $$childTail = null ;
131
131
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
/**
@@ -201,9 +198,6 @@ function $RootScopeProvider(){
201
198
if ( isolate ) {
202
199
child = new Scope ( ) ;
203
200
child . $root = this . $root ;
204
- // ensure that there is just one async queue per $rootScope and its children
205
- child . $$asyncQueue = this . $$asyncQueue ;
206
- child . $$postDigestQueue = this . $$postDigestQueue ;
207
201
} else {
208
202
// Only create a child scope class if somebody asks for one,
209
203
// but cache it to allow the VM to optimize lookups.
@@ -704,8 +698,6 @@ function $RootScopeProvider(){
704
698
$digest : function ( ) {
705
699
var watch , value , last ,
706
700
watchers ,
707
- asyncQueue = this . $$asyncQueue ,
708
- postDigestQueue = this . $$postDigestQueue ,
709
701
length ,
710
702
dirty , ttl = TTL ,
711
703
next , current , target = this ,
@@ -870,6 +862,10 @@ function $RootScopeProvider(){
870
862
if ( this . $$prevSibling ) this . $$prevSibling . $$nextSibling = this . $$nextSibling ;
871
863
if ( this . $$nextSibling ) this . $$nextSibling . $$prevSibling = this . $$prevSibling ;
872
864
865
+ // Disable listeners, watchers and apply/digest methods
866
+ this . $destroy = this . $digest = this . $apply = this . $evalAsync = this . $applyAsync = noop ;
867
+ this . $on = this . $watch = this . $watchGroup = function ( ) { return noop ; } ;
868
+ this . $$listeners = { } ;
873
869
874
870
// All of the code below is bogus code that works around V8's memory leak via optimized code
875
871
// and inline caches.
@@ -880,15 +876,7 @@ function $RootScopeProvider(){
880
876
// - https://github.com/angular/angular.js/issues/1313#issuecomment-10378451
881
877
882
878
this . $parent = this . $$nextSibling = this . $$prevSibling = this . $$childHead =
883
- this . $$childTail = this . $root = null ;
884
-
885
- // don't reset these to null in case some async task tries to register a listener/watch/task
886
- this . $$listeners = { } ;
887
- this . $$watchers = this . $$asyncQueue = this . $$postDigestQueue = [ ] ;
888
-
889
- // prevent NPEs since these methods have references to properties we nulled out
890
- this . $destroy = this . $digest = this . $apply = noop ;
891
- this . $on = this . $watch = this . $watchGroup = function ( ) { return noop ; } ;
879
+ this . $$childTail = this . $root = this . $$watchers = null ;
892
880
} ,
893
881
894
882
/**
@@ -955,19 +943,19 @@ function $RootScopeProvider(){
955
943
$evalAsync : function ( expr ) {
956
944
// if we are outside of an $digest loop and this is the first time we are scheduling async
957
945
// task also schedule async auto-flush
958
- if ( ! $rootScope . $$phase && ! $rootScope . $$ asyncQueue. length ) {
946
+ if ( ! $rootScope . $$phase && ! asyncQueue . length ) {
959
947
$browser . defer ( function ( ) {
960
- if ( $rootScope . $$ asyncQueue. length ) {
948
+ if ( asyncQueue . length ) {
961
949
$rootScope . $digest ( ) ;
962
950
}
963
951
} ) ;
964
952
}
965
953
966
- this . $$ asyncQueue. push ( { scope : this , expression : expr } ) ;
954
+ asyncQueue . push ( { scope : this , expression : expr } ) ;
967
955
} ,
968
956
969
957
$$postDigest : function ( fn ) {
970
- this . $$ postDigestQueue. push ( fn ) ;
958
+ postDigestQueue . push ( fn ) ;
971
959
} ,
972
960
973
961
/**
@@ -1051,7 +1039,7 @@ function $RootScopeProvider(){
1051
1039
*/
1052
1040
$applyAsync : function ( expr ) {
1053
1041
var scope = this ;
1054
- expr && $rootScope . $$ applyAsyncQueue. push ( $applyAsyncExpression ) ;
1042
+ expr && applyAsyncQueue . push ( $applyAsyncExpression ) ;
1055
1043
scheduleApplyAsync ( ) ;
1056
1044
1057
1045
function $applyAsyncExpression ( ) {
@@ -1260,6 +1248,11 @@ function $RootScopeProvider(){
1260
1248
1261
1249
var $rootScope = new Scope ( ) ;
1262
1250
1251
+ //The internal queues. Expose them on the $rootScope for debugging/testing purposes.
1252
+ var asyncQueue = $rootScope . $$asyncQueue = [ ] ;
1253
+ var postDigestQueue = $rootScope . $$postDigestQueue = [ ] ;
1254
+ var applyAsyncQueue = $rootScope . $$applyAsyncQueue = [ ] ;
1255
+
1263
1256
return $rootScope ;
1264
1257
1265
1258
@@ -1293,10 +1286,9 @@ function $RootScopeProvider(){
1293
1286
function initWatchVal ( ) { }
1294
1287
1295
1288
function flushApplyAsync ( ) {
1296
- var queue = $rootScope . $$applyAsyncQueue ;
1297
- while ( queue . length ) {
1289
+ while ( applyAsyncQueue . length ) {
1298
1290
try {
1299
- queue . shift ( ) ( ) ;
1291
+ applyAsyncQueue . shift ( ) ( ) ;
1300
1292
} catch ( e ) {
1301
1293
$exceptionHandler ( e ) ;
1302
1294
}
0 commit comments