fix(view): fixed ProtoViewFactory to get all property bindings
This commit is contained in:
parent
ac80df0959
commit
7f976381d5
|
@ -116,8 +116,9 @@ export class ProtoViewFactory {
|
|||
var sortedDirectives = ListWrapper.map(elementBinders, b => new SortedDirectives(b.directives, directives));
|
||||
|
||||
var variableBindings = this._createVariableBindings(renderProtoView);
|
||||
var protoLocals = this._createProtoLocals(renderProtoView);
|
||||
var protoLocals = this._createProtoLocals(variableBindings);
|
||||
var variableNames = this._createVariableNames(parentProtoView, protoLocals);
|
||||
|
||||
var protoChangeDetector = this._createProtoChangeDetector(elementBinders, sortedDirectives, componentBinding, variableNames);
|
||||
var protoView = new AppProtoView(renderProtoView.render, protoChangeDetector, variableBindings, protoLocals, variableNames);
|
||||
|
||||
|
@ -128,9 +129,9 @@ export class ProtoViewFactory {
|
|||
return protoView;
|
||||
}
|
||||
|
||||
_createProtoLocals(renderProtoView):Map {
|
||||
_createProtoLocals(varBindings:Map):Map {
|
||||
var protoLocals = MapWrapper.create();
|
||||
MapWrapper.forEach(renderProtoView.variableBindings, (mappedName, varName) => {
|
||||
MapWrapper.forEach(varBindings, (mappedName, varName) => {
|
||||
MapWrapper.set(protoLocals, mappedName, null);
|
||||
});
|
||||
return protoLocals;
|
||||
|
@ -141,6 +142,11 @@ export class ProtoViewFactory {
|
|||
MapWrapper.forEach(renderProtoView.variableBindings, (mappedName, varName) => {
|
||||
MapWrapper.set(variableBindings, varName, mappedName);
|
||||
});
|
||||
ListWrapper.forEach(renderProtoView.elementBinders, binder => {
|
||||
MapWrapper.forEach(binder.variableBindings, (mappedName, varName) => {
|
||||
MapWrapper.set(variableBindings, varName, mappedName);
|
||||
});
|
||||
});
|
||||
return variableBindings;
|
||||
}
|
||||
|
||||
|
|
|
@ -365,7 +365,6 @@ export function main() {
|
|||
}));
|
||||
|
||||
tb.createView(MyComp, {context: ctx}).then((view) => {
|
||||
|
||||
expect(view.rawView.locals).not.toBe(null);
|
||||
expect(view.rawView.locals.get('alice')).toBeAnInstanceOf(ChildComp);
|
||||
|
||||
|
@ -373,6 +372,20 @@ export function main() {
|
|||
})
|
||||
}));
|
||||
|
||||
it('should make the assigned component accessible in property bindings', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
tb.overrideView(MyComp, new View({
|
||||
template: '<p><child-cmp var-alice></child-cmp>{{alice.ctxProp}}</p>',
|
||||
directives: [ChildComp]
|
||||
}));
|
||||
|
||||
tb.createView(MyComp, {context: ctx}).then((view) => {
|
||||
view.detectChanges();
|
||||
|
||||
expect(view.rootNodes).toHaveText('hellohello'); // this first one is the component, the second one is the text binding
|
||||
async.done();
|
||||
})
|
||||
}));
|
||||
|
||||
it('should assign two component instances each with a var-', inject([TestBed, AsyncTestCompleter], (tb, async) => {
|
||||
tb.overrideView(MyComp, new View({
|
||||
template: '<p><child-cmp var-alice></child-cmp><child-cmp var-bob></p>',
|
||||
|
|
Loading…
Reference in New Issue