File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -670,11 +670,12 @@ function $RootScopeProvider(){
670670 */
671671 $destroy : function ( ) {
672672 // 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 ;
674674 var parent = this . $parent ;
675675
676676 this . $broadcast ( '$destroy' ) ;
677677 this . $$destroyed = true ;
678+ if ( this === $rootScope ) return ;
678679
679680 if ( parent . $$childHead == this ) parent . $$childHead = this . $$nextSibling ;
680681 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() {
599599 } ) ) ;
600600
601601
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 ) ;
603605 $rootScope . $destroy ( ) ;
604606 $rootScope . $digest ( ) ;
605607 expect ( log ) . toEqual ( '123' ) ;
608+ expect ( spy ) . toHaveBeenCalled ( ) ;
609+ expect ( $rootScope . $$destroyed ) . toBe ( true ) ;
606610 } ) ) ;
607611
608612
You can’t perform that action at this time.
0 commit comments