@@ -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
@@ -205,15 +223,7 @@ function $RootScopeProvider() {
205
223
// Only create a child scope class if somebody asks for one,
206
224
// but cache it to allow the VM to optimize lookups.
207
225
if ( ! this . $$ChildScope ) {
208
- this . $$ChildScope = function ChildScope ( ) {
209
- this . $$watchers = this . $$nextSibling =
210
- this . $$childHead = this . $$childTail = null ;
211
- this . $$listeners = { } ;
212
- this . $$listenerCount = { } ;
213
- this . $id = nextUid ( ) ;
214
- this . $$ChildScope = null ;
215
- } ;
216
- this . $$ChildScope . prototype = this ;
226
+ this . $$ChildScope = createChildScopeClass ( this ) ;
217
227
}
218
228
child = new this . $$ChildScope ( ) ;
219
229
}
@@ -231,13 +241,9 @@ function $RootScopeProvider() {
231
241
// prototypically. In all other cases, this property needs to be set
232
242
// when the parent scope is destroyed.
233
243
// The listener needs to be added after the parent is set
234
- if ( isolate || parent != this ) child . $on ( '$destroy' , destroyChild ) ;
244
+ if ( isolate || parent != this ) child . $on ( '$destroy' , destroyChildScope ) ;
235
245
236
246
return child ;
237
-
238
- function destroyChild ( ) {
239
- child . $$destroyed = true ;
240
- }
241
247
} ,
242
248
243
249
/**
0 commit comments