Skip to content
Myr

Merge branch 'fix-array-patch' of https://github.com/ryuever/immer into ryuever-fix-array-patch

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 acc5e54, fb5c316 · Browse files · 2 files+26 added−4 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+26 added−4 removed

  • tests:+15 added−0 removed
  • other:+11 added−4 removed

2 files+26 added−4 removed

modified:__tests__/patch.js+15 added
646 unmodified lines
647 ]648 )649})650651describe.only("arrays - delete", () => {652 runPatchTest(653 {654 x: [655 {a: 1, b: 2},656 {c: 3, d: 4}657 ]658 },659 d => {660 delete d.x[1].c661 },662 [{op: "remove", path: ["x", 1, "c"]}]663 )664})665666describe("sets - add - 1", () => {667 runPatchTest(668 new Set([1]),669 d => {
344 unmodified lines
modified:src/es5.ts+11 added-4 removed
239 unmodified lines
240 assigned[key] = false241 markChangedES5(state)242 }243 })244 } else if (type === ProxyType.ES5Array) {244 } else if (type === ProxyType.ES5Array && hasArrayChanges(state)) {245 markChangedES5(state)246 assigned.length = true245 if (hasArrayChanges(state)) {246 markChangedES5(state)247 assigned.length = true248 }249250 if (draft.length < base.length) {251 for (let i = draft.length; i < base.length; i++) assigned[i] = false252 } else {253 for (let i = base.length; i < draft.length; i++) assigned[i] = true254 }255256 // Minimum count is enough, the other parts has been processed.257 const min = Math.min(draft.length, base.length)258252 for (let i = 0; i < draft.length; i++) {259 for (let i = 0; i < min; i++) {260 // Only untouched indices trigger recursion.261 if (assigned[i] === undefined) markChangesRecursively(draft[i])262 }263 }
47 unmodified lines