This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -955,7 +955,6 @@ function $RootScopeProvider() {
955
955
// Disable listeners, watchers and apply/digest methods
956
956
this . $destroy = this . $digest = this . $apply = this . $evalAsync = this . $applyAsync = noop ;
957
957
this . $on = this . $watch = this . $watchGroup = function ( ) { return noop ; } ;
958
- this . $$listeners = { } ;
959
958
960
959
// Disconnect the next sibling to prevent `cleanUpScope` destroying those too
961
960
this . $$nextSibling = null ;
@@ -1375,6 +1374,7 @@ function $RootScopeProvider() {
1375
1374
1376
1375
if ( current . $$listenerCount [ name ] === 0 ) {
1377
1376
delete current . $$listenerCount [ name ] ;
1377
+ delete current . $$listeners [ name ] ;
1378
1378
}
1379
1379
} while ( ( current = current . $parent ) ) ;
1380
1380
}
Original file line number Diff line number Diff line change @@ -2364,6 +2364,26 @@ describe('Scope', function() {
2364
2364
expect ( $rootScope . $$listenerCount ) . toEqual ( { abc : 1 } ) ;
2365
2365
expect ( child . $$listenerCount ) . toEqual ( { abc : 1 } ) ;
2366
2366
} ) ) ;
2367
+
2368
+
2369
+ it ( 'should deallocate the $$listenerCount entry when reaching 0' , inject ( function ( $rootScope ) {
2370
+ var child = $rootScope . $new ( ) ;
2371
+
2372
+ child . $on ( 'abc' , noop ) ( ) ;
2373
+
2374
+ expect ( 'abc' in $rootScope . $$listenerCount ) . toBe ( false ) ;
2375
+ expect ( 'abc' in child . $$listenerCount ) . toBe ( false ) ;
2376
+ } ) ) ;
2377
+
2378
+
2379
+ it ( 'should deallocate the $$listeners entry when empty' , inject ( function ( $rootScope ) {
2380
+ var child = $rootScope . $new ( ) ;
2381
+
2382
+ child . $on ( 'abc' , noop ) ( ) ;
2383
+
2384
+ expect ( 'abc' in $rootScope . $$listeners ) . toBe ( false ) ;
2385
+ expect ( 'abc' in child . $$listeners ) . toBe ( false ) ;
2386
+ } ) ) ;
2367
2387
} ) ;
2368
2388
} ) ;
2369
2389
You can’t perform that action at this time.
0 commit comments