This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +7
-2
lines changed
2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -670,11 +670,12 @@ function $RootScopeProvider(){
670
670
*/
671
671
$destroy : function ( ) {
672
672
// we can't destroy the root scope or a scope that has been already destroyed
673
- if ( $rootScope == this || this . $$destroyed ) return ;
673
+ if ( this . $$destroyed ) return ;
674
674
var parent = this . $parent ;
675
675
676
676
this . $broadcast ( '$destroy' ) ;
677
677
this . $$destroyed = true ;
678
+ if ( this === $rootScope ) return ;
678
679
679
680
if ( parent . $$childHead == this ) parent . $$childHead = this . $$nextSibling ;
680
681
if ( parent . $$childTail == this ) parent . $$childTail = this . $$prevSibling ;
Original file line number Diff line number Diff line change @@ -599,10 +599,14 @@ describe('Scope', function() {
599
599
} ) ) ;
600
600
601
601
602
- it ( 'should ignore remove on root' , inject ( function ( $rootScope ) {
602
+ it ( 'should broadcast $destroy on rootScope' , inject ( function ( $rootScope ) {
603
+ var spy = spyOn ( angular , 'noop' ) ;
604
+ $rootScope . $on ( '$destroy' , angular . noop ) ;
603
605
$rootScope . $destroy ( ) ;
604
606
$rootScope . $digest ( ) ;
605
607
expect ( log ) . toEqual ( '123' ) ;
608
+ expect ( spy ) . toHaveBeenCalled ( ) ;
609
+ expect ( $rootScope . $$destroyed ) . toBe ( true ) ;
606
610
} ) ) ;
607
611
608
612
You can’t perform that action at this time.
0 commit comments