Skip to content

Commit

Permalink
fix(runtime): use unpatched parentNode as a fallback while inserting …
Browse files Browse the repository at this point in the history
…newChild
  • Loading branch information
itsjustaplant committed Feb 4, 2025
1 parent bc8cc65 commit cba9889
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/runtime/dom-extras.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ const patchInsertBefore = (HostElementPrototype: HTMLElement) => {
});
if (found) return newChild;
}
return (this as d.RenderNode).__insertBefore(newChild, currentChild);
// If currentChild's parent is not the same node with the patched node, use the currentChild's unpatched parentNode for inserting the newChild
const parentNode = (currentChild as d.PatchedSlotNode)?.__parentNode;
const node = parentNode && !this.isSameNode(parentNode) ? parentNode : this;
return (node as d.RenderNode).__insertBefore(newChild, currentChild);
};
};

Expand Down

0 comments on commit cba9889

Please sign in to comment.