You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, big fan of immer here! I think I've found a small issue though:
When adding an element to an object ({}) and then immediately removing it (via applyPatches), produceWithPatches returns an empty patch set as expected, since ultimately nothing has changed.
When doing the same with a Map however, the reported resulting patch set contains only a patch for removing the element. Replaying that patch set (or replaying the reverse patch set on top of the produced result) would produce inconsistent results.
The resulting patches are different depending on whether the changes were applied to an object or a Map.
Expected behavior
I'd expect the patches to be the same in both cases. At least, I'd expect the patches resulting for Map to be consistent -- for example, an add patch followed by a remove patch.
Environment
We only accept bug reports against the latest Immer version.
Immer version:
I filed this report against the latest version of Immer
Occurs with setUseProxies(true)
Occurs with setUseProxies(false) (ES5 only)
The text was updated successfully, but these errors were encountered:
jscheid
added a commit
to jscheid/immer
that referenced
this issue
Dec 3, 2021
馃悰 Bug Report
Hi, big fan of immer here! I think I've found a small issue though:
When adding an element to an object (
{}
) and then immediately removing it (viaapplyPatches
),produceWithPatches
returns an empty patch set as expected, since ultimately nothing has changed.When doing the same with a
Map
however, the reported resulting patch set contains only a patch for removing the element. Replaying that patch set (or replaying the reverse patch set on top of the produced result) would produce inconsistent results.Link to repro
https://codesandbox.io/s/immer-addthenremovepatches-for-map-d4jve?file=/tests/immer.test.ts
To Reproduce
Steps to reproduce the behavior: see repro.
Observed behavior
The resulting patches are different depending on whether the changes were applied to an object or a Map.
Expected behavior
I'd expect the patches to be the same in both cases. At least, I'd expect the patches resulting for
Map
to be consistent -- for example, anadd
patch followed by aremove
patch.Environment
We only accept bug reports against the latest Immer version.
setUseProxies(true)
setUseProxies(false)
(ES5 only)The text was updated successfully, but these errors were encountered: