Skip to content
Myr

Merge branch 'proxy-set-ignore-equality' of https://github.com/smirea/immer into smirea-proxy-set-ignore-equality

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parents cabcd3d, 462f506 · Browse files · 2 files+24 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+24 added−0 removed

  • tests:+21 added−0 removed
  • other:+3 added−0 removed

2 files+24 added−0 removed

modified:__tests__/patch.js+21 added
1254 unmodified lines
1255 expect(newMap.get("constructor").polluted).toBe("yes")1256 expect(newMap.get("prototype").polluted).toBe("yes")1257 expect(obj.polluted).toBe(undefined)1258})12591260test("#648 assigning object to itself should not change patches", () => {1261 const input = {1262 obj: {1263 value: 2001264 }1265 }12661267 const [nextState, patches] = produceWithPatches(input, draft => {1268 draft.obj.value = 11269 draft.obj = draft.obj1270 })12711272 expect(patches).toEqual([1273 {1274 op: "replace",1275 path: ["obj", "value"],1276 value: 11277 }1278 ])1279})
modified:src/core/proxy.ts+3 added
155 unmodified lines
156 return true157 prepareCopy(state)158 markChanged(state)159 }160161 if (state.copy_![prop] === value && typeof value !== "number") return true162163 // @ts-ignore164 state.copy_![prop] = value165 state.assigned_[prop] = true166 return true
107 unmodified lines