diff --git a/CHANGELOG.md b/CHANGELOG.md index acb6d6c..d8b4fdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log ## [unreleased] +* Fix cannot update value to null (https://github.com/substantial/updeep/issues/8) * Add umd distribution builds via webpack. (https://github.com/aaronjensen/updeep/issues/3) ## [0.2.2] diff --git a/lib/update.js b/lib/update.js index e7e6187..1a0fc87 100644 --- a/lib/update.js +++ b/lib/update.js @@ -5,7 +5,7 @@ import assign from 'lodash/object/assign'; function resolveUpdates(updates, obj = {}) { return reduce(updates, (acc, value, key) => { let updatedValue = value; - if (!Array.isArray(value) && typeof value === 'object') { + if (!Array.isArray(value) && value !== null && typeof value === 'object') { updatedValue = update(value, obj[key]); } else if (typeof value === 'function') { updatedValue = value(obj[key]); diff --git a/test/index.js b/test/index.js index ca27f91..37e2bb9 100644 --- a/test/index.js +++ b/test/index.js @@ -109,4 +109,8 @@ describe('updeep', () => { expect(Object.isFrozen(result)).to.be.true; expect(Object.isFrozen(result.foo)).to.be.true; }); + + it('assigns null values', () => { + expect(u({isNull: null}, {})).to.eql({isNull: null}); + }); });