Skip to content

Commit 9448d78

Browse files
committed
refactor(ProtoElementInjector): change instantiate to take positional args
1 parent b5f6417 commit 9448d78

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

modules/benchmarks/src/element_injector/instantiate_benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function run () {
1010
var bindings = [A, B, C];
1111
var proto = new ProtoElementInjector(null, 0, bindings);
1212
for (var i = 0; i < ITERATIONS; ++i) {
13-
var ei = proto.instantiate({view:null, parentElementInjector: null});
13+
var ei = proto.instantiate(null,null);
1414
ei.instantiateDirectives(appInjector);
1515
}
1616
}

modules/benchmarks/src/element_injector/instantiate_benchmark_codegen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function run () {
1818

1919
var proto = new ProtoElementInjector(null, 0, bindings);
2020
for (var i = 0; i < ITERATIONS; ++i) {
21-
var ei = proto.instantiate({view:null, parentElementInjector: null});
21+
var ei = proto.instantiate(null,null);
2222
ei.instantiateDirectives(appInjector);
2323
}
2424
}

modules/benchmarks/src/element_injector/instantiate_directive_benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function run () {
99

1010
var bindings = [A, B, C];
1111
var proto = new ProtoElementInjector(null, 0, bindings);
12-
var ei = proto.instantiate({view:null, parentElementInjector: null});
12+
var ei = proto.instantiate(null,null);
1313

1414
for (var i = 0; i < ITERATIONS; ++i) {
1515
ei.clearDirectives();

modules/core/src/compiler/element_injector.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {Math} from 'facade/math';
33
import {List, ListWrapper} from 'facade/collection';
44
import {Injector, Key, Dependency, bind, Binding, NoProviderError, ProviderError, CyclicDependencyError} from 'di/di';
55
import {Parent, Ancestor} from 'core/annotations/visibility';
6+
import {View} from './view';
67
import {StaticKeys} from './static_keys';
78

89
var _MAX_DIRECTIVE_CONSTRUCTION_COUNTER = 10;
@@ -148,12 +149,8 @@ export class ProtoElementInjector {
148149
}
149150
}
150151

151-
instantiate({view, parentElementInjector}):ElementInjector {
152-
return new ElementInjector({
153-
proto: this,
154-
parent: parentElementInjector,
155-
view: view
156-
});
152+
instantiate(parent:ElementInjector, view):ElementInjector {
153+
return new ElementInjector(this, parent, view);
157154
}
158155

159156
_createBinding(bindingOrType) {
@@ -226,7 +223,7 @@ export class ElementInjector extends TreeNode {
226223
@FIELD('_obj8:Object')
227224
@FIELD('_obj9:Object')
228225
@FIELD('_view:View')
229-
constructor({proto, parent, view}) {
226+
constructor(proto:ProtoElementInjector, parent:ElementInjector, view) {
230227
super(parent);
231228
this._proto = proto;
232229
this._view = view;

modules/core/src/compiler/view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class ProtoView {
115115

116116
static _createElementInjector(element, parent:ElementInjector, proto:ProtoElementInjector) {
117117
//TODO: vsavkin: pass element to `proto.instantiate()` once https://github.com/angular/angular/pull/98 is merged
118-
return proto.hasBindings ? proto.instantiate({view:null, parentElementInjector:parent}) : null;
118+
return proto.hasBindings ? proto.instantiate(parent, null) : null;
119119
}
120120

121121
static _rootElementInjectors(injectors) {

modules/core/test/compiler/element_injector_spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ export function main() {
6868

6969
function injector(bindings, appInjector = null, props = null) {
7070
if (isBlank(appInjector)) appInjector = new Injector([]);
71-
if (isBlank(props)) props = {};
71+
if (isBlank(props)) props = {"view" : null};
7272

7373
var proto = new ProtoElementInjector(null, 0, bindings);
74-
var inj = proto.instantiate({view: props["view"], parentElementInjector:null});
74+
var inj = proto.instantiate(null, props["view"]);
7575
inj.instantiateDirectives(appInjector);
7676
return inj;
7777
}
@@ -80,11 +80,11 @@ export function main() {
8080
var inj = new Injector([]);
8181

8282
var protoParent = new ProtoElementInjector(null, 0, parentBindings);
83-
var parent = protoParent.instantiate({view: null, parentElementInjector: null});
83+
var parent = protoParent.instantiate(null, null);
8484
parent.instantiateDirectives(inj);
8585

8686
var protoChild = new ProtoElementInjector(protoParent, 1, childBindings);
87-
var child = protoChild.instantiate({view: null, parentElementInjector: parent});
87+
var child = protoChild.instantiate(parent, null);
8888
child.instantiateDirectives(inj);
8989

9090
return child;
@@ -97,9 +97,9 @@ export function main() {
9797
var protoChild1 = new ProtoElementInjector(protoParent, 1, []);
9898
var protoChild2 = new ProtoElementInjector(protoParent, 2, []);
9999

100-
var p = protoParent.instantiate({view: null, parentElementInjector: null});
101-
var c1 = protoChild1.instantiate({view: null, parentElementInjector: p});
102-
var c2 = protoChild2.instantiate({view: null, parentElementInjector: p});
100+
var p = protoParent.instantiate(null, null);
101+
var c1 = protoChild1.instantiate(p, null);
102+
var c2 = protoChild2.instantiate(p, null);
103103

104104
expect(humanize(p, [
105105
[p, 'parent'],

0 commit comments

Comments
 (0)