Skip to content

Commit

Permalink
Proposed fix for #819 (B)
Browse files Browse the repository at this point in the history
We are already cloning and iterating over the Set. If we go a step further and clear it before iteration, and re-add all children during iteration, we can preserve insertion order.
  • Loading branch information
jdip committed Sep 9, 2022
1 parent b28d0b3 commit ab864a6
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/core/finalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ function finalize(rootScope: ImmerScope, value: any, path?: PatchPath) {
// For sets we clone before iterating, otherwise we can get in endless loop due to modifying during iteration, see #628
// To preserve insertion order in all cases we then clear the set
// And we let finalizeProperty know it needs to re-add non-draft children back to the target
// Although the original test case doesn't seem valid anyway, so if this in the way we can turn the next line
// back to each(result, ....)
let resultEach = result
let isSet = false
if (state.type_ === ProxyType.Set) {
Expand Down

0 comments on commit ab864a6

Please sign in to comment.