diff --git a/modules/di/src/binding.js b/modules/di/src/binding.js index 986174dd4c..c98bbf03e3 100644 --- a/modules/di/src/binding.js +++ b/modules/di/src/binding.js @@ -50,7 +50,7 @@ export class BindingBuilder { ); } - toFactory(factoryFunction:Function, {dependencies=null}={}):Binding { + toFactory(factoryFunction:Function, dependencies:List = null):Binding { return new Binding( Key.get(this.token), reflector.convertToFactory(factoryFunction), @@ -59,7 +59,7 @@ export class BindingBuilder { ); } - toAsyncFactory(factoryFunction:Function, {dependencies=null}={}):Binding { + toAsyncFactory(factoryFunction:Function, dependencies:List = null):Binding { return new Binding( Key.get(this.token), reflector.convertToFactory(factoryFunction), diff --git a/modules/di/src/injector.js b/modules/di/src/injector.js index 4698e92f86..09ff218c90 100644 --- a/modules/di/src/injector.js +++ b/modules/di/src/injector.js @@ -19,11 +19,11 @@ function _isWaiting(obj):bool { export class Injector { - constructor(bindings:List) { + constructor(bindings:List, parent:Injector = null) { var flatten = _flattenBindings(bindings, MapWrapper.create()); this._bindings = this._createListOfBindings(flatten); this._instances = this._createInstances(); - this._parent = null; //TODO: vsavkin make a parameter + this._parent = parent; this._asyncStrategy = new _AsyncInjectorStrategy(this); this._syncStrategy = new _SyncInjectorStrategy(this); @@ -46,9 +46,7 @@ export class Injector { } createChild(bindings:List):Injector { - var inj = new Injector(bindings); - inj._parent = this; //TODO: vsavkin: change it when optional parameters are working - return inj; + return new Injector(bindings, this); } diff --git a/modules/di/test/di/injector_spec.js b/modules/di/test/di/injector_spec.js index da07617e55..0aec6acf57 100644 --- a/modules/di/test/di/injector_spec.js +++ b/modules/di/test/di/injector_spec.js @@ -125,7 +125,7 @@ export function main() { it('should support overriding factory dependencies', function () { var injector = new Injector([ Engine, - bind(Car).toFactory((e) => new SportsCar(e), {dependencies: [Engine]}) + bind(Car).toFactory((e) => new SportsCar(e), [Engine]) ]); var car = injector.get(Car);