@@ -80,9 +80,27 @@ function $RootScopeProvider() {
8080 return TTL ;
8181 } ;
8282
83+ function createChildScopeClass ( parent ) {
84+ function ChildScope ( ) {
85+ this . $$watchers = this . $$nextSibling =
86+ this . $$childHead = this . $$childTail = null ;
87+ this . $$listeners = { } ;
88+ this . $$listenerCount = { } ;
89+ this . $$watchersCount = 0 ;
90+ this . $id = nextUid ( ) ;
91+ this . $$ChildScope = null ;
92+ }
93+ ChildScope . prototype = parent ;
94+ return ChildScope ;
95+ }
96+
8397 this . $get = [ '$injector' , '$exceptionHandler' , '$parse' , '$browser' ,
8498 function ( $injector , $exceptionHandler , $parse , $browser ) {
8599
100+ function destroyChildScope ( $event ) {
101+ $event . currentScope . $$destroyed = true ;
102+ }
103+
86104 /**
87105 * @ngdoc type
88106 * @name $rootScope.Scope
@@ -206,16 +224,7 @@ function $RootScopeProvider() {
206224 // Only create a child scope class if somebody asks for one,
207225 // but cache it to allow the VM to optimize lookups.
208226 if ( ! this . $$ChildScope ) {
209- this . $$ChildScope = function ChildScope ( ) {
210- this . $$watchers = this . $$nextSibling =
211- this . $$childHead = this . $$childTail = null ;
212- this . $$listeners = { } ;
213- this . $$listenerCount = { } ;
214- this . $$watchersCount = 0 ;
215- this . $id = nextUid ( ) ;
216- this . $$ChildScope = null ;
217- } ;
218- this . $$ChildScope . prototype = this ;
227+ this . $$ChildScope = createChildScopeClass ( this ) ;
219228 }
220229 child = new this . $$ChildScope ( ) ;
221230 }
@@ -233,13 +242,9 @@ function $RootScopeProvider() {
233242 // prototypically. In all other cases, this property needs to be set
234243 // when the parent scope is destroyed.
235244 // The listener needs to be added after the parent is set
236- if ( isolate || parent != this ) child . $on ( '$destroy' , destroyChild ) ;
245+ if ( isolate || parent != this ) child . $on ( '$destroy' , destroyChildScope ) ;
237246
238247 return child ;
239-
240- function destroyChild ( ) {
241- child . $$destroyed = true ;
242- }
243248 } ,
244249
245250 /**
0 commit comments