Open pcelica88 opened 4 years ago
It anyone is wondering, this is just a bug/misleading on the demo page.
It correctly patches it:
const left = { "ids": [1, 2, 3] }
const right = { "ids": [4, 1, 2, 3] }
const delta = jsondiffpatch.diff(left, right) // { ids: { '0': [ 4 ], _t: 'a' } }
const reconstructedRight = jsondiffpatch.patch(left, delta) // { ids: [ 4, 1, 2, 3 ] }
I noticed that there is a problem with comparing arrays. The problem only occurs:
when we add a new element to the beginning of the array
and when we are showing unchanged values
Example
var left = {"ids": [1, 2, 3]};
var right = {"ids": [4, 1, 2, 3]};
var delta = jsondiffpatch.diff(left, right);
Results In this case only the replacement of the first element will be detected, and what I need is completely added new element without replacing first one.Can you please check if this is a bug or this should work like this. Thanks