Skip to content
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

Fails for case of newly added property with a value of null #7

Open
zwilliam88 opened this issue Aug 31, 2017 · 5 comments
Open

Fails for case of newly added property with a value of null #7

zwilliam88 opened this issue Aug 31, 2017 · 5 comments

Comments

@zwilliam88
Copy link

A simple test case:

    it 'should properly handle new null property', ->
      before = {}
      after = { newProp: null }
      changesets.applyChanges before, changesets.diff before, after
      expect(after).to.eql before

Fails with "TypeError: Cannot read property 'length' of undefined"

if change.value? or change.type is changeset.op.REMOVE

should probably be:

      if !change.changes

In its current form applyChanges calls applyBranchChanges for the add of a new property with a value of null. applyBranchChanges expects a changes array to exist on the change and calls length on undefined.

@diego-palla
Copy link

Yep, this happens :(
Any expected fix?

@viruschidai
Copy link
Owner

Anyone wants to PR?

@0x80
Copy link
Contributor

0x80 commented May 7, 2020

Shit, I just wasted a lot of time before checking the issues here 🤦

Wonder why this hasn't been picked up in two years @viruschidai? But happy to find a solution.

@0x80
Copy link
Contributor

0x80 commented May 7, 2020

#20

In the meantime you can do something like: yarn add https://github.com/0x80/diff-json\#topic/fix-newly-added-null

@0x80
Copy link
Contributor

0x80 commented Sep 4, 2021

@viruschidai Could you please release v2.0.1 with this fix?

I waited a year before you merged the PR in April, but there has been no new release so I still can't use normal npm version control for this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants