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
pull/2342/head
David Sheldrick 2023-12-18 20:18:31 +00:00 zatwierdzone przez GitHub
rodzic 509ee3a6e4
commit 1d29ac3c42
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 3 dodań i 3 usunięć

Wyświetl plik

@ -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 */

Wyświetl plik

@ -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