File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -756,6 +756,7 @@ function $RootScopeProvider(){
756
756
757
757
// prevent NPEs since these methods have references to properties we nulled out
758
758
this . $destroy = this . $digest = this . $apply = noop ;
759
+ this . $on = this . $watch = function ( ) { return noop ; } ;
759
760
760
761
761
762
/* jshint -W103 */
Original file line number Diff line number Diff line change @@ -876,6 +876,28 @@ describe('Scope', function() {
876
876
$rootScope . $broadcast ( EVENT ) ;
877
877
expect ( spy . callCount ) . toBe ( 1 ) ;
878
878
} ) ) ;
879
+
880
+
881
+ it ( "should do nothing when a child event listener is registered after parent's destruction" ,
882
+ inject ( function ( $rootScope ) {
883
+ var parent = $rootScope . $new ( ) ,
884
+ child = parent . $new ( ) ;
885
+
886
+ parent . $destroy ( ) ;
887
+ var fn = child . $on ( 'someEvent' , function ( ) { } ) ;
888
+ expect ( fn ) . toBe ( noop ) ;
889
+ } ) ) ;
890
+
891
+
892
+ it ( "should do nothing when a child watch is registered after parent's destruction" ,
893
+ inject ( function ( $rootScope ) {
894
+ var parent = $rootScope . $new ( ) ,
895
+ child = parent . $new ( ) ;
896
+
897
+ parent . $destroy ( ) ;
898
+ var fn = child . $watch ( 'somePath' , function ( ) { } ) ;
899
+ expect ( fn ) . toBe ( noop ) ;
900
+ } ) ) ;
879
901
} ) ;
880
902
881
903
You can’t perform that action at this time.
0 commit comments