Skip to content

Commit

Permalink
fix(runtime-dom): fix static content re-insertion
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yyx990803 committed Jan 23, 2022
1 parent 4be1037 commit 9aa5dfd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/runtime-dom/src/nodeOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export const nodeOps: Omit<RendererOptions<Node, Element>, 'patchProp'> = {
insertStaticContent(content, parent, anchor, isSVG, start, end) {
// <parent> before | first ... last | anchor </parent>
const before = anchor ? anchor.previousSibling : parent.lastChild
if (start && end) {
// #5308 can only take cached path if:
// - has a single root node
// - nextSibling info is still available
if (start && (start === end || start.nextSibling)) {
// cached
while (true) {
parent.insertBefore(start!.cloneNode(true), anchor)
Expand Down

0 comments on commit 9aa5dfd

Please sign in to comment.