Skip to content

Commit

Permalink
fix(renderer): add check for already relocated nodes to avoid reordering
Browse files Browse the repository at this point in the history
another check is added to avoid changing already relocated nodes order by updating the anchor node which is used by insertBefore

fixes one of the issues raised in ionic-team#5335
  • Loading branch information
yigityuce committed Mar 13, 2024
1 parent c69160e commit f2d7cdd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/runtime/vdom/vdom-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1049,12 +1049,18 @@ render() {
(insertBeforeNode && insertBeforeNode.nodeType === NODE_TYPE.ElementNode)
) {
let orgLocationNode = nodeToRelocate['s-ol']?.previousSibling as d.RenderNode | null;

while (orgLocationNode) {
let refNode = orgLocationNode['s-nr'] ?? null;

if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
refNode = refNode.nextSibling as any;
refNode = refNode.nextSibling as d.RenderNode | null;

// If the refNode is the same node to be relocated or another element's slot reference, keep searching to find the
// correct relocation target
while (refNode === nodeToRelocate || refNode['s-sr']) {
refNode = refNode.nextSibling as d.RenderNode | null;
}

if (!refNode || !refNode['s-nr']) {
insertBeforeNode = refNode;
break;
Expand Down

0 comments on commit f2d7cdd

Please sign in to comment.