fix(view_manager): allow to create host views even if there is an embedded view at the same place.

This commit is contained in:
Tobias Bosch 2015-07-16 15:17:52 -07:00
parent b785503543
commit 116b64de25
2 changed files with 18 additions and 1 deletions

View File

@ -188,7 +188,8 @@ export class AppViewManager {
var embeddedFragmentView = contextView.getNestedView(contextBoundElementIndex);
var view;
if (isPresent(embeddedFragmentView) && !embeddedFragmentView.hydrated()) {
if (protoView.type === ViewType.EMBEDDED && isPresent(embeddedFragmentView) &&
!embeddedFragmentView.hydrated()) {
// Case 1: instantiate the first view of a template that has been merged into a parent
view = embeddedFragmentView;
this._attachRenderView(parentView, boundElementIndex, atIndex, view);

View File

@ -300,6 +300,22 @@ export function main() {
});
describe('create a host view', () => {
it('should always create a new view and not use the embedded view', () => {
var newHostPv = createHostPv([createNestedElBinder(createComponentPv())]);
var newHostView =
internalView(manager.createViewInContainer(vcRef, 0, wrapPv(newHostPv), null));
expect(newHostView.proto).toBe(newHostPv);
expect(newHostView).not.toBe(hostView.views[2]);
expect(viewListener.spy('viewCreated')).toHaveBeenCalledWith(newHostView);
expect(renderer.spy('createView'))
.toHaveBeenCalledWith(newHostPv.mergeMapping.renderProtoViewRef,
newHostPv.mergeMapping.renderFragmentCount);
});
});
});
});