fix(ivy): properly insert views in front of views with an empty element container (#33647)

PR Close #33647
This commit is contained in:
Pawel Kozlowski 2019-11-07 10:55:59 +01:00 committed by Kara Erickson
parent 1d429b2165
commit 056236cafd
2 changed files with 11 additions and 1 deletions

View File

@ -676,7 +676,12 @@ function getFirstNativeNode(lView: LView, tNode: TNode | null): RNode|null {
return lContainer[NATIVE];
}
} else if (tNodeType === TNodeType.ElementContainer || tNodeType === TNodeType.IcuContainer) {
return getFirstNativeNode(lView, tNode.child);
const elIcuContainerChild = tNode.child;
if (elIcuContainerChild !== null) {
return getFirstNativeNode(lView, elIcuContainerChild);
} else {
return getNativeByTNode(tNode, lView);
}
} else {
const componentView = findComponentView(lView);
const componentHost = componentView[T_HOST] as TElementNode;

View File

@ -327,6 +327,11 @@ describe('view insertion', () => {
.toBe('insert|before');
});
it('should insert before a view with the empty ng-container as the first root node', () => {
expect(createAndInsertViews(`<ng-container></ng-container>|before`).textContent)
.toBe('insert|before');
});
it('should insert before a view with ICU container inside a ng-container as the first root node',
() => {
expect(