Prevent diff mutation (#2336)

We had a bug in `squashRecordDiffs` where it could potentially mutate
'updated' entries.

### Change Type

- [x] `patch` — Bug fix


### Release Notes

- Fix `squashRecordDiffs` to prevent a bug where it mutates the
'updated' entires
This commit is contained in:
David Sheldrick 2023-12-18 20:18:31 +00:00 committed by GitHub
parent 509ee3a6e4
commit 1d29ac3c42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -884,7 +884,7 @@ export function squashRecordDiffs<T extends UnknownRecord>(
continue
}
if (result.updated[id]) {
result.updated[id][1] = to
result.updated[id] = [result.updated[id][0], to]
delete result.removed[id]
continue
}
@ -940,7 +940,7 @@ function squashHistoryEntries<T extends UnknownRecord>(
result.push(current)
return result
return devFreeze(result)
}
/** @public */

View file

@ -62,7 +62,7 @@ describe('Translating', () => {
editor.select(id)
const shape = editor.getShape<TLLineShape>(id)!
shape.rotation = Math.PI / 2
editor.updateShape({ ...shape, rotation: Math.PI / 2 })
editor.pointerDown(250, 250, { target: 'shape', shape: shape })
editor.pointerMove(300, 400) // Move shape by 50, 150