Palindrom / JSONPatcherProxy

ES6 proxy powered JSON Object observer that emits JSON patches when changes occur to your object tree.
94 stars 14 forks source link

Inconsistent patch generation when adding `undefined` elements to an array #52

Open eriksunsol opened 5 years ago

eriksunsol commented 5 years ago

This is a continuation of dicussion here: https://github.com/Palindrom/JSONPatcherProxy/pull/45#discussion_r311897775

Steps to reproduce

See failing test here: 7cf32fd09593fef2751abc51114267e4a14f3897

The test extends an array with 5 elements to 9 elements with undefined or null values.

Expected result

Four add patches to add null elements.

Actual result

One add patch and one replace patch.

warpech commented 5 years ago

I decided to implement the solution in the already opened PR https://github.com/Palindrom/JSONPatcherProxy/pull/45, because I was afraid of creating a conflict that's troublesome to merge.

warpech commented 5 years ago

This issue is partially solved in #45, but there are even more edge cases:

There are 3 kinds of arrays to test:

There are many kinds of array operations to test: