Fails for case of newly added property with a value of null
zwilliam88 opened this issue · comments
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"
diff-json/src/changesets.coffee
Line 212 in 4356e69
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.
Yep, this happens :(
Any expected fix?
Anyone wants to PR?
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.
In the meantime you can do something like: yarn add https://github.com/0x80/diff-json\#topic/fix-newly-added-null
@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.