Skip to content

Commit fca0c18

Browse files
minimize the movement of the nodes during active element preservation.
Co-authored-by: MichaelWest22 <michael@latent.nz>
1 parent 9aed82c commit fca0c18

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/idiomorph.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,14 @@ var Idiomorph = (function () {
488488
function preserveActiveElementPath(oldParent, insertionPoint, newChild, ctx) {
489489
const [activeElement, newActiveElement] =
490490
ctx.activeElementMap.get(oldParent) || [];
491+
if (!activeElement) return insertionPoint;
491492
// are we about to morph the active element or its ancestor?
492493
if (newActiveElement === newChild) {
494+
const beforePoint = activeElement.nextSibling;
493495
while (insertionPoint && insertionPoint !== activeElement) {
494-
// "move" the active element to the left by moving the current node to end of the parent
496+
// "move" the active element to the left by moving the current node after the active element
495497
let nextInsertionPoint = insertionPoint.nextSibling;
496-
moveBefore(oldParent, insertionPoint, null);
498+
moveBefore(oldParent, insertionPoint, beforePoint);
497499
insertionPoint = nextInsertionPoint;
498500
}
499501
}

0 commit comments

Comments
 (0)