From 056236cafd8fd19defb32f729213bed6c6b40a85 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Thu, 7 Nov 2019 10:55:59 +0100 Subject: [PATCH] fix(ivy): properly insert views in front of views with an empty element container (#33647) PR Close #33647 --- packages/core/src/render3/node_manipulation.ts | 7 ++++++- packages/core/test/acceptance/view_insertion_spec.ts | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/core/src/render3/node_manipulation.ts b/packages/core/src/render3/node_manipulation.ts index a7a0b13d44..2c1ed5c056 100644 --- a/packages/core/src/render3/node_manipulation.ts +++ b/packages/core/src/render3/node_manipulation.ts @@ -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; diff --git a/packages/core/test/acceptance/view_insertion_spec.ts b/packages/core/test/acceptance/view_insertion_spec.ts index 090401d357..fadc44211c 100644 --- a/packages/core/test/acceptance/view_insertion_spec.ts +++ b/packages/core/test/acceptance/view_insertion_spec.ts @@ -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(`|before`).textContent) + .toBe('insert|before'); + }); + it('should insert before a view with ICU container inside a ng-container as the first root node', () => { expect(