Skip to content

Commit

Permalink
fix: clone the oldCh array
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Jan 3, 2022
1 parent c620819 commit e8dac64
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/@lwc/engine-core/src/3rdparty/snabbdom/snabbdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ export function updateDynamicChildren(
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm!);
} else {
patchVnode(elmToMove, newStartVnode);
// Delete the old child, but copy the array since it is read-only.
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
// so we only care about the `oldCh` object inside this function.
const oldChClone = [...oldCh];
oldChClone[idxInOld] = undefined as any;
oldCh = oldChClone;
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm!);
}
}
Expand Down

0 comments on commit e8dac64

Please sign in to comment.