-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
should generate nice remove op on array.splice #65
Comments
👍 Same issue here. |
@Pavek, @winduptoy I have created branch for this fiddling with @Pavek test case passes with native |
It seems working without native The problem comes with shim, as we keep mirror as deep clone so there is no way to check that obj = { items: [{name:"obj1"}, {name:"obj2"}, {name:"obj3"}]}; new @warpech any ideas? |
We could keep a shallow clone of arrays to check that. This way you could compare |
The question is where to keep those clones? as currently we keep only one |
Please see #204 (comment) I don't think we'll implement a fix for this. Because I think our observation efforts will be mainly focused on JSONPatcherProxy. Closing but feel free to reopen. |
Why const JSONPatcherProxy = require('jsonpatcherproxy');
var myObj = { items: ["a", "b", "c"]};
var jsonPatcherProxy = new JSONPatcherProxy( myObj );
var observedObject = jsonPatcherProxy.observe(true);
myObj.items.splice(1, 1); // <<-- removing second item in-place
var patches = jsonPatcherProxy.generate(); |
Because that's what the JS engine actually does. If you watch the traps in slow-motion (so to say) you see the engine replacing (shifting left) array elements one by one starting from the spliced item until it reaches the end then it removes the last element, which only then triggers the And this makes sense. You want |
Here's the test that fails:
Now it fails as following:
The text was updated successfully, but these errors were encountered: