From 9dcc1984ec7cbf5c929d006ce250821f99e66512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sampo=20Kivist=C3=B6?= Date: Mon, 16 May 2022 07:27:25 +0300 Subject: [PATCH] Improve patch method performance by moving componentWillMove hook check (#1598) --- packages/inferno/src/DOM/patching.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/inferno/src/DOM/patching.ts b/packages/inferno/src/DOM/patching.ts index af9a66fd4..2150e99d5 100644 --- a/packages/inferno/src/DOM/patching.ts +++ b/packages/inferno/src/DOM/patching.ts @@ -63,7 +63,6 @@ export function patch( replaceWithNewNode(lastVNode, nextVNode, parentDOM, context, isSVG, lifecycle, animations); } else { // Last vNode is not in use, it has crashed at application level. Just mount nextVNode and ignore last one - // TODO: What does this mean? Should we not not call animations here? mount(nextVNode, parentDOM, context, isSVG, nextNode, lifecycle, animations); } } else if (nextFlags & VNodeFlags.Element) { @@ -79,11 +78,6 @@ export function patch( } else { patchPortal(lastVNode, nextVNode, context, lifecycle, animations); } - - // Invoke move animations when all moves have been calculated - if (animations.componentWillMove.length > 0) { - callAllMoveAnimationHooks(animations.componentWillMove); - } } export function patchSingleTextChild(lastChildren, nextChildren, parentDOM: Element) { @@ -785,6 +779,10 @@ function patchKeyedChildrenComplex( j--; } } + // Invoke move animations when all moves have been calculated + if (animations.componentWillMove.length > 0) { + callAllMoveAnimationHooks(animations.componentWillMove); + } } else if (patched !== bLeft) { // when patched count doesn't match b length we need to insert those new ones // loop backwards so we can use insertBefore