Skip to content

Commit

Permalink
Improve patch method performance by moving componentWillMove hook che…
Browse files Browse the repository at this point in the history
…ck (#1598)
  • Loading branch information
Havunen authored May 16, 2022
1 parent 6b2a5cc commit 9dcc198
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/inferno/src/DOM/patching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9dcc198

Please sign in to comment.