Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit f7e1ea7

Browse files
committed
refactor(rootScope): Move the creation of the child scope class into its own function
1 parent ca8b0b2 commit f7e1ea7

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/ng/rootScope.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ 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

@@ -210,16 +224,7 @@ function $RootScopeProvider() {
210224
// Only create a child scope class if somebody asks for one,
211225
// but cache it to allow the VM to optimize lookups.
212226
if (!this.$$ChildScope) {
213-
this.$$ChildScope = function ChildScope() {
214-
this.$$watchers = this.$$nextSibling =
215-
this.$$childHead = this.$$childTail = null;
216-
this.$$listeners = {};
217-
this.$$listenerCount = {};
218-
this.$$watchersCount = 0;
219-
this.$id = nextUid();
220-
this.$$ChildScope = null;
221-
};
222-
this.$$ChildScope.prototype = this;
227+
this.$$ChildScope = createChildScopeClass(this);
223228
}
224229
child = new this.$$ChildScope();
225230
}

0 commit comments

Comments
 (0)