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 ;
@@ -1364,6 +1363,7 @@ function $RootScopeProvider() {
1364
1363
1365
1364
if ( current . $$listenerCount [ name ] === 0 ) {
1366
1365
delete current . $$listenerCount [ name ] ;
1366
+ delete current . $$listeners [ name ] ;
1367
1367
}
1368
1368
} while ( ( current = current . $parent ) ) ;
1369
1369
}
Original file line number Diff line number Diff line change @@ -2562,6 +2562,26 @@ describe('Scope', function() {
2562
2562
expect ( secondListener ) . not . toHaveBeenCalled ( ) ;
2563
2563
} ) ;
2564
2564
} ) ;
2565
+
2566
+
2567
+ it ( 'should deallocate the $$listenerCount entry when reaching 0' , inject ( function ( $rootScope ) {
2568
+ var child = $rootScope . $new ( ) ;
2569
+
2570
+ child . $on ( 'abc' , noop ) ( ) ;
2571
+
2572
+ expect ( 'abc' in $rootScope . $$listenerCount ) . toBe ( false ) ;
2573
+ expect ( 'abc' in child . $$listenerCount ) . toBe ( false ) ;
2574
+ } ) ) ;
2575
+
2576
+
2577
+ it ( 'should deallocate the $$listeners entry when empty' , inject ( function ( $rootScope ) {
2578
+ var child = $rootScope . $new ( ) ;
2579
+
2580
+ child . $on ( 'abc' , noop ) ( ) ;
2581
+
2582
+ expect ( 'abc' in $rootScope . $$listeners ) . toBe ( false ) ;
2583
+ expect ( 'abc' in child . $$listeners ) . toBe ( false ) ;
2584
+ } ) ) ;
2565
2585
} ) ;
2566
2586
} ) ;
2567
2587
You can’t perform that action at this time.
0 commit comments