Skip to content

Commit 9aa5dfd

Browse files
committed
fix(runtime-dom): fix static content re-insertion
fix #5308 The regression was introduced in ed9eb62. In the cached code path, we attempt re-insertion by cloning cached nodes. However if the static fragment was removed as component root, it loses the nodes between start and end because each node was removed individually. Therefore the cached path can only be taken if the fragment has a single node, or it was removed as part of a parent tree so the sibling information is still available.
1 parent 4be1037 commit 9aa5dfd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/runtime-dom/src/nodeOps.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ export const nodeOps: Omit<RendererOptions<Node, Element>, 'patchProp'> = {
7676
insertStaticContent(content, parent, anchor, isSVG, start, end) {
7777
// <parent> before | first ... last | anchor </parent>
7878
const before = anchor ? anchor.previousSibling : parent.lastChild
79-
if (start && end) {
79+
// #5308 can only take cached path if:
80+
// - has a single root node
81+
// - nextSibling info is still available
82+
if (start && (start === end || start.nextSibling)) {
8083
// cached
8184
while (true) {
8285
parent.insertBefore(start!.cloneNode(true), anchor)

0 commit comments

Comments
 (0)