This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,7 +136,6 @@ function $RootScopeProvider(){
136136 this . $$phase = this . $parent = this . $$watchers =
137137 this . $$nextSibling = this . $$prevSibling =
138138 this . $$childHead = this . $$childTail = null ;
139- this . $destructor = noop ;
140139 this [ 'this' ] = this . $root = this ;
141140 this . $$asyncQueue = [ ] ;
142141 this . $$listeners = { } ;
@@ -458,6 +457,8 @@ function $RootScopeProvider(){
458457 if ( this . $root == this ) return ; // we can't remove the root node;
459458 var parent = this . $parent ;
460459
460+ this . $broadcast ( '$destroy' ) ;
461+
461462 if ( parent . $$childHead == this ) parent . $$childHead = this . $$nextSibling ;
462463 if ( parent . $$childTail == this ) parent . $$childTail = this . $$prevSibling ;
463464 if ( this . $$prevSibling ) this . $$prevSibling . $$nextSibling = this . $$nextSibling ;
Original file line number Diff line number Diff line change 22
33describe ( 'Scope' , function ( ) {
44
5+ beforeEach ( module ( provideLog ) ) ;
6+
7+
58 describe ( '$root' , function ( ) {
69 it ( 'should point to itself' , inject ( function ( $rootScope ) {
710 expect ( $rootScope . $root ) . toEqual ( $rootScope ) ;
@@ -393,6 +396,15 @@ describe('Scope', function() {
393396 $rootScope . $digest ( ) ;
394397 expect ( log ) . toEqual ( '12' ) ;
395398 } ) ) ;
399+
400+
401+ it ( 'should broadcast the $destroy event' , inject ( function ( $rootScope , log ) {
402+ first . $on ( '$destroy' , log . fn ( 'first' ) ) ;
403+ first . $new ( ) . $on ( '$destroy' , log . fn ( 'first-child' ) ) ;
404+
405+ first . $destroy ( ) ;
406+ expect ( log ) . toEqual ( 'first; first-child' ) ;
407+ } ) ) ;
396408 } ) ;
397409
398410
You can’t perform that action at this time.
0 commit comments