refactor(ivy): simplify getFirstNativeNode processing of LContainer (#33647)

PR Close #33647
This commit is contained in:
Pawel Kozlowski 2019-11-07 11:42:58 +01:00 committed by Kara Erickson
parent 05d7c575e4
commit 9d99c7244f

View File

@ -668,18 +668,7 @@ function getFirstNativeNode(lView: LView, tNode: TNode | null): RNode|null {
if (tNodeType === TNodeType.Element) { if (tNodeType === TNodeType.Element) {
return getNativeByTNode(tNode, lView); return getNativeByTNode(tNode, lView);
} else if (tNodeType === TNodeType.Container) { } else if (tNodeType === TNodeType.Container) {
const lContainer = lView[tNode.index]; return getBeforeNodeForView(-1, lView[tNode.index]);
if (lContainer.length > CONTAINER_HEADER_OFFSET) {
const firstView = lContainer[CONTAINER_HEADER_OFFSET];
const firstTNodeOfView = firstView[TVIEW].firstChild;
if (firstTNodeOfView !== null) {
return getFirstNativeNode(firstView, firstTNodeOfView);
} else {
return lContainer[NATIVE];
}
} else {
return lContainer[NATIVE];
}
} else if (tNodeType === TNodeType.ElementContainer || tNodeType === TNodeType.IcuContainer) { } else if (tNodeType === TNodeType.ElementContainer || tNodeType === TNodeType.IcuContainer) {
const elIcuContainerChild = tNode.child; const elIcuContainerChild = tNode.child;
if (elIcuContainerChild !== null) { if (elIcuContainerChild !== null) {
@ -710,7 +699,10 @@ export function getBeforeNodeForView(viewIndexInContainer: number, lContainer: L
const nextViewIndex = CONTAINER_HEADER_OFFSET + viewIndexInContainer + 1; const nextViewIndex = CONTAINER_HEADER_OFFSET + viewIndexInContainer + 1;
if (nextViewIndex < lContainer.length) { if (nextViewIndex < lContainer.length) {
const lView = lContainer[nextViewIndex] as LView; const lView = lContainer[nextViewIndex] as LView;
return getFirstNativeNode(lView, lView[TVIEW].firstChild); const firstTNodeOfView = lView[TVIEW].firstChild;
if (firstTNodeOfView !== null) {
return getFirstNativeNode(lView, firstTNodeOfView);
}
} }
return lContainer[NATIVE]; return lContainer[NATIVE];