@@ -80,9 +80,27 @@ function $RootScopeProvider() {
80
80
return TTL ;
81
81
} ;
82
82
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
+
83
97
this . $get = [ '$injector' , '$exceptionHandler' , '$parse' , '$browser' ,
84
98
function ( $injector , $exceptionHandler , $parse , $browser ) {
85
99
100
+ function destroyChildScope ( $event ) {
101
+ $event . currentScope . $$destroyed = true ;
102
+ }
103
+
86
104
/**
87
105
* @ngdoc type
88
106
* @name $rootScope.Scope
@@ -206,16 +224,7 @@ function $RootScopeProvider() {
206
224
// Only create a child scope class if somebody asks for one,
207
225
// but cache it to allow the VM to optimize lookups.
208
226
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 ) ;
219
228
}
220
229
child = new this . $$ChildScope ( ) ;
221
230
}
@@ -233,13 +242,9 @@ function $RootScopeProvider() {
233
242
// prototypically. In all other cases, this property needs to be set
234
243
// when the parent scope is destroyed.
235
244
// 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 ) ;
237
246
238
247
return child ;
239
-
240
- function destroyChild ( ) {
241
- child . $$destroyed = true ;
242
- }
243
248
} ,
244
249
245
250
/**
0 commit comments