Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 6722e1a

Browse files
committed
fix(scope): createChild now requires context
1 parent 6176ba3 commit 6722e1a

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

lib/core/scope.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@ class Scope {
249249
ScopeStream on(String name) =>
250250
_Streams.on(this, rootScope._exceptionHandler, name);
251251

252-
Scope createChild([Object childContext]) {
253-
if (childContext == null) childContext = context;
252+
Scope createChild(Object childContext) {
254253
var child = new Scope(childContext, rootScope, this,
255254
_depth + 1, _nextChildIndex++,
256255
watchGroup.newGroup(childContext),

lib/core_dom/common.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ class DirectiveRef {
2929
* services from the provided modules.
3030
*/
3131
Injector forceNewDirectivesAndFilters(Injector injector, List<Module> modules) {
32-
modules.add(new Module()
33-
..factory(Scope, (i) => i.parent.get(Scope).createChild()));
32+
modules.add(new Module()..factory(Scope, (i) {
33+
var scope = i.parent.get(Scope);
34+
return scope.createChild(new PrototypeMap(scope.context));
35+
}));
3436
return injector.createChild(modules,
3537
forceNewInstances: [DirectiveMap, FilterMap]);
3638
}

test/core/scope_spec.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ main() => describe('scope', () {
192192
}));
193193

194194
it('children should point to root', inject((RootScope rootScope) {
195-
var child = rootScope.createChild();
195+
var child = rootScope.createChild(new PrototypeMap(rootScope.context));
196196
expect(child.rootScope).toEqual(rootScope);
197-
expect(child.createChild().rootScope).toEqual(rootScope);
197+
expect(child.createChild(new PrototypeMap(rootScope.context)).rootScope).toEqual(rootScope);
198198
}));
199199
});
200200

@@ -206,10 +206,10 @@ main() => describe('scope', () {
206206

207207

208208
it('should point to parent', inject((RootScope rootScope) {
209-
var child = rootScope.createChild();
209+
var child = rootScope.createChild(new PrototypeMap(rootScope.context));
210210
expect(rootScope.parentScope).toEqual(null);
211211
expect(child.parentScope).toEqual(rootScope);
212-
expect(child.createChild().parentScope).toEqual(child);
212+
expect(child.createChild(new PrototypeMap(rootScope.context)).parentScope).toEqual(child);
213213
}));
214214
});
215215
});
@@ -226,7 +226,7 @@ main() => describe('scope', () {
226226

227227
it(r'should add listener for both emit and broadcast events', inject((RootScope rootScope) {
228228
var log = '',
229-
child = rootScope.createChild();
229+
child = rootScope.createChild(new PrototypeMap(rootScope.context));
230230

231231
eventFn(event) {
232232
expect(event).not.toEqual(null);
@@ -246,7 +246,7 @@ main() => describe('scope', () {
246246

247247
it(r'should return a function that deregisters the listener', inject((RootScope rootScope) {
248248
var log = '';
249-
var child = rootScope.createChild();
249+
var child = rootScope.createChild(new PrototypeMap(rootScope.context));
250250
var subscription;
251251

252252
eventFn(e) {

0 commit comments

Comments
 (0)