Closed eaorak closed 5 years ago
I'm getting a 'Cannot read property 'splice' of undefined' error on the line below when I try to apply the diff with a simple object. The code is as follows:
` const diffpatch = jsondiffpatch.create()
const o1 = { f1: 'field1', f2: 100, f3: 'field3', f4: [1, 2] } const o2 = { f1: 'field1-new', f2: 100, f3: 'field3', f4: [1, 2, 3] } const diff = diffpatch.diff(o1, o2) diffpatch.patch({}, diff) `
It works fine when there are no arrays in the object or the array contents are identical but fails when there's a difference. What could the issue be?
https://github.com/benjamine/jsondiffpatch/blob/0c4323e9bff23ae231f4bff231ceed4df2b48be5/src/filters/arrays.js#L328
It seems like there has to be an empty array in the original object. So it works fine when I change patch as follows:
diffpatch.patch({f4: []}, diff)
I'm getting a 'Cannot read property 'splice' of undefined' error on the line below when I try to apply the diff with a simple object. The code is as follows:
` const diffpatch = jsondiffpatch.create()
const o1 = { f1: 'field1', f2: 100, f3: 'field3', f4: [1, 2] } const o2 = { f1: 'field1-new', f2: 100, f3: 'field3', f4: [1, 2, 3] } const diff = diffpatch.diff(o1, o2) diffpatch.patch({}, diff) `
It works fine when there are no arrays in the object or the array contents are identical but fails when there's a difference. What could the issue be?
https://github.com/benjamine/jsondiffpatch/blob/0c4323e9bff23ae231f4bff231ceed4df2b48be5/src/filters/arrays.js#L328