-
Notifications
You must be signed in to change notification settings - Fork 215
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
Generated patch contains array length
#14
Comments
I have prepared a sample test case: it('should generate the same patch using Object.observe and shim', function() { var arr1 = [ ["Albert", "Einstein"], ["Erwin", "Shrodinger"] ]; var arr2 = arr1.slice(); var newRecord = ['Niels', 'Bohr']; var observer1 = jsonpatch.observe(arr1); arr1.push(newRecord); var objectObservePatches = jsonpatch.generate(observer1); var _observe = Object.observe; Object.observe = undefined; var observer2 = jsonpatch.observe(arr2); arr2.push(newRecord); var shimPatches = jsonpatch.generate(observer2); //fails because objectObservePathes has an extra patch with "length" property expect(objectObservePatches).toEqual(shimPatches); Object.observe = _observe; }); |
After studying http://tools.ietf.org/html/rfc6902 and some sample test cases here https://github.com/mikemccabe/json-patch-tests I think the only good solution is to NOT include |
Thanks @psmolenski, I added your test to the test suite |
This issue is fixed in v0.3.3 |
It seems that such behavior is not a bug in Chrome, but desired behavior for That's the main difference with |
I'll clean our |
In native Object.observe version (Chrome 28 & 30), array
length
is reported as part of the change records.I don't think this is an error in Chrome, but I think JSON-Patch should filter out
length
from it's own generated patchSee http://jsfiddle.net/U4mZJ/3/
For a sample array, generated patch is:
I will fix this soon
The text was updated successfully, but these errors were encountered: