From d5f96a887d86652d1809c0de2cefd56736dc1c34 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Wed, 22 May 2019 16:41:35 +0200 Subject: [PATCH] refactor(ivy): refactor getBeforeNodeForView for readability (#30614) PR Close #30614 --- packages/core/src/render3/node_manipulation.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/core/src/render3/node_manipulation.ts b/packages/core/src/render3/node_manipulation.ts index 2392393567..8a586c5fd7 100644 --- a/packages/core/src/render3/node_manipulation.ts +++ b/packages/core/src/render3/node_manipulation.ts @@ -729,15 +729,14 @@ function getHighestElementOrICUContainer(tNode: TNode): TNode { return tNode; } -export function getBeforeNodeForView(index: number, lContainer: LContainer) { - const containerNative = lContainer[NATIVE]; - - if (index + 1 < lContainer.length - CONTAINER_HEADER_OFFSET) { - const view = lContainer[CONTAINER_HEADER_OFFSET + index + 1] as LView; - const viewTNode = view[T_HOST] as TViewNode; - return viewTNode.child ? getNativeByTNode(viewTNode.child, view) : containerNative; +export function getBeforeNodeForView(viewIndexInContainer: number, lContainer: LContainer): RNode { + const nextViewIndex = CONTAINER_HEADER_OFFSET + viewIndexInContainer + 1; + if (nextViewIndex < lContainer.length) { + const lView = lContainer[nextViewIndex] as LView; + const tViewNodeChild = (lView[T_HOST] as TViewNode).child; + return tViewNodeChild !== null ? getNativeByTNode(tViewNodeChild, lView) : lContainer[NATIVE]; } else { - return containerNative; + return lContainer[NATIVE]; } }