diff --git a/src/idiomorph.js b/src/idiomorph.js index 8c16afc..f11b3b4 100644 --- a/src/idiomorph.js +++ b/src/idiomorph.js @@ -490,10 +490,11 @@ var Idiomorph = (function () { ctx.activeElementMap.get(oldParent) || []; // are we about to morph the active element or its ancestor? if (newActiveElement === newChild) { + const beforePoint = activeElement.nextSibling while (insertionPoint && insertionPoint !== activeElement) { - // "move" the active element to the left by moving the current node to end of the parent + // "move" the active element to the left by moving the current node after the active element let nextInsertionPoint = insertionPoint.nextSibling; - moveBefore(oldParent, insertionPoint, null); + moveBefore(oldParent, insertionPoint, beforePoint); insertionPoint = nextInsertionPoint; } }