refactor(ivy): refactor getBeforeNodeForView for readability (#30614)

PR Close #30614
This commit is contained in:
Pawel Kozlowski 2019-05-22 16:41:35 +02:00 committed by Matias Niemelä
parent 68cd0cab8c
commit d5f96a887d
1 changed files with 7 additions and 8 deletions

View File

@ -729,15 +729,14 @@ function getHighestElementOrICUContainer(tNode: TNode): TNode {
return tNode; return tNode;
} }
export function getBeforeNodeForView(index: number, lContainer: LContainer) { export function getBeforeNodeForView(viewIndexInContainer: number, lContainer: LContainer): RNode {
const containerNative = lContainer[NATIVE]; const nextViewIndex = CONTAINER_HEADER_OFFSET + viewIndexInContainer + 1;
if (nextViewIndex < lContainer.length) {
if (index + 1 < lContainer.length - CONTAINER_HEADER_OFFSET) { const lView = lContainer[nextViewIndex] as LView;
const view = lContainer[CONTAINER_HEADER_OFFSET + index + 1] as LView; const tViewNodeChild = (lView[T_HOST] as TViewNode).child;
const viewTNode = view[T_HOST] as TViewNode; return tViewNodeChild !== null ? getNativeByTNode(tViewNodeChild, lView) : lContainer[NATIVE];
return viewTNode.child ? getNativeByTNode(viewTNode.child, view) : containerNative;
} else { } else {
return containerNative; return lContainer[NATIVE];
} }
} }