Giter Site home page Giter Site logo

Comments (6)

psmolenski avatar psmolenski commented on August 27, 2024

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;
    });

from json-patch.

warpech avatar warpech commented on August 27, 2024

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 length in the produced patch. I will submit a fix

from json-patch.

warpech avatar warpech commented on August 27, 2024

Thanks @psmolenski, I added your test to the test suite

from json-patch.

warpech avatar warpech commented on August 27, 2024

This issue is fixed in v0.3.3

from json-patch.

tomalec avatar tomalec commented on August 27, 2024

It seems that such behavior is not a bug in Chrome, but desired behavior for Object.observe it's even mentioned in spec.

That's the main difference with Array.observe, which I believe we should use for array(-like) nodes.

from json-patch.

tomalec avatar tomalec commented on August 27, 2024

I'll clean our .length logic at 0552ac6. So users may use 'length' property name for non-array objects. For arrays, we will handle splice change type.

from json-patch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.