fix(view): ViewPort light should come from the direct parent
This commit is contained in:
parent
b953956a35
commit
fc1b791a7a
@ -261,6 +261,10 @@ export class ProtoElementInjector {
|
|||||||
return new ElementInjector(this, parent, host, eventCallbacks);
|
return new ElementInjector(this, parent, host, eventCallbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
directParent(): ProtoElementInjector {
|
||||||
|
return this.distanceToParent < 2 ? this.parent : null;
|
||||||
|
}
|
||||||
|
|
||||||
_createBinding(bindingOrType) {
|
_createBinding(bindingOrType) {
|
||||||
if (bindingOrType instanceof DirectiveBinding) {
|
if (bindingOrType instanceof DirectiveBinding) {
|
||||||
return bindingOrType;
|
return bindingOrType;
|
||||||
|
6
modules/angular2/src/core/compiler/view.js
vendored
6
modules/angular2/src/core/compiler/view.js
vendored
@ -401,7 +401,7 @@ export class ProtoView {
|
|||||||
// viewPorts
|
// viewPorts
|
||||||
var viewPort = null;
|
var viewPort = null;
|
||||||
if (isPresent(binder.templateDirective)) {
|
if (isPresent(binder.templateDirective)) {
|
||||||
var destLightDom = this._parentElementLightDom(protoElementInjector, preBuiltObjects);
|
var destLightDom = this._directParentElementLightDom(protoElementInjector, preBuiltObjects);
|
||||||
viewPort = new ViewPort(view, element, binder.nestedProtoView, elementInjector, destLightDom);
|
viewPort = new ViewPort(view, element, binder.nestedProtoView, elementInjector, destLightDom);
|
||||||
ListWrapper.push(viewPorts, viewPort);
|
ListWrapper.push(viewPorts, viewPort);
|
||||||
}
|
}
|
||||||
@ -456,8 +456,8 @@ export class ProtoView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_parentElementLightDom(protoElementInjector:ProtoElementInjector, preBuiltObjects:List):LightDom {
|
_directParentElementLightDom(protoElementInjector:ProtoElementInjector, preBuiltObjects:List):LightDom {
|
||||||
var p = protoElementInjector.parent;
|
var p = protoElementInjector.directParent();
|
||||||
return isPresent(p) ? preBuiltObjects[p.index].lightDom : null;
|
return isPresent(p) ? preBuiltObjects[p.index].lightDom : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +153,26 @@ export function main() {
|
|||||||
return shadow;
|
return shadow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
describe("ProtoElementInjector", () => {
|
||||||
|
describe("direct parent", () => {
|
||||||
|
it("should return parent proto injector when distance is 1", () => {
|
||||||
|
var distance = 1;
|
||||||
|
var protoParent = new ProtoElementInjector(null, 0, []);
|
||||||
|
var protoChild = new ProtoElementInjector(protoParent, 1, [], false, distance);
|
||||||
|
|
||||||
|
expect(protoChild.directParent()).toEqual(protoParent);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return null otherwise", () => {
|
||||||
|
var distance = 2;
|
||||||
|
var protoParent = new ProtoElementInjector(null, 0, []);
|
||||||
|
var protoChild = new ProtoElementInjector(protoParent, 1, [], false, distance);
|
||||||
|
|
||||||
|
expect(protoChild.directParent()).toEqual(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("ElementInjector", function () {
|
describe("ElementInjector", function () {
|
||||||
describe("instantiate", function () {
|
describe("instantiate", function () {
|
||||||
it("should create an element injector", function () {
|
it("should create an element injector", function () {
|
||||||
|
@ -77,6 +77,31 @@ export function main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should redistribute direct child viewports when the light dom changes", (done) => {
|
||||||
|
var temp = '<multiple-content-tags>' +
|
||||||
|
'<div><div template="manual" class="left">A</div></div>' +
|
||||||
|
'<div>B</div>' +
|
||||||
|
'</multiple-content-tags>';
|
||||||
|
|
||||||
|
compile(temp, (view, lc) => {
|
||||||
|
var dir = view.elementInjectors[1].get(ManualTemplateDirective);
|
||||||
|
|
||||||
|
expect(view.nodes).toHaveText('(, B)');
|
||||||
|
|
||||||
|
dir.show();
|
||||||
|
lc.tick();
|
||||||
|
|
||||||
|
expect(view.nodes).toHaveText('(, AB)');
|
||||||
|
|
||||||
|
dir.hide();
|
||||||
|
lc.tick();
|
||||||
|
|
||||||
|
expect(view.nodes).toHaveText('(, B)');
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should redistribute when the light dom changes", (done) => {
|
it("should redistribute when the light dom changes", (done) => {
|
||||||
var temp = '<multiple-content-tags>' +
|
var temp = '<multiple-content-tags>' +
|
||||||
'<div template="manual" class="left">A</div>' +
|
'<div template="manual" class="left">A</div>' +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user