diff --git a/package.json b/package.json index 0ecbec6..0414e9c 100644 --- a/package.json +++ b/package.json @@ -56,9 +56,7 @@ "release": "webpack --progress --hide-modules --config ./build/webpack.release.js && NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.min.js && webpack --progress --hide-modules --config ./build/webpack.release.full.js && NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.full.min.js", "prepublish": "yarn run lint && yarn run test && yarn run build" }, - "dependencies": { - "lodash.merge": "^4.6.0" - }, + "dependencies": {}, "peerDependencies": { "chart.js": "^2.6.0", "vue": "^2.4.2" diff --git a/src/helpers/options.js b/src/helpers/options.js index ccae233..8e3645d 100644 --- a/src/helpers/options.js +++ b/src/helpers/options.js @@ -1,5 +1,4 @@ -import merge from 'lodash.merge' - export function mergeOptions (obj, src) { - return merge(obj, src) + let mutableObj = Object.assign({}, obj) + return Object.assign(mutableObj, src) } diff --git a/test/unit/specs/helpers/options.spec.js b/test/unit/specs/helpers/options.spec.js index d05ad75..47cefb9 100644 --- a/test/unit/specs/helpers/options.spec.js +++ b/test/unit/specs/helpers/options.spec.js @@ -15,16 +15,40 @@ describe('mergeOptions.js', () => { c: 'c' } + const an = { + a: { + a: 'a' + }, + b: { + b: 'a' + } + } + + const bn = { + a: { + a: 'a' + }, + b: { + b: 'b' + } + } + it('should replace old a and b if a and b are new', () => { - let ab = mergeOptions(a, b) + const ab = mergeOptions(a, b) expect(ab).to.have.property('a').and.to.equal('b') expect(ab).to.have.property('b').and.to.equal('b') }) it('should add c if c is new', () => { - let ac = mergeOptions(a, c) + const ac = mergeOptions(a, c) expect(ac).to.have.property('a').and.to.equal('a') expect(ac).to.have.property('b').and.to.equal('a') expect(ac).to.have.property('c').and.to.equal('c') }) + + it('should replace old a and b if a and b are new in nested objects', () => { + const ab = mergeOptions(an, bn) + expect(ab).to.have.deep.property('a.a').and.to.equal('a') + expect(ab).to.have.deep.property('b.b').and.to.equal('b') + }) }) diff --git a/yarn.lock b/yarn.lock index 6edd212..1842a54 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3538,10 +3538,6 @@ lodash.keysin@^4.0.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.keysin/-/lodash.keysin-4.2.0.tgz#8cc3fb35c2d94acc443a1863e02fa40799ea6f28" -lodash.merge@^4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5" - lodash.mergewith@^4.0.0, lodash.mergewith@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.0.tgz#150cf0a16791f5903b8891eab154609274bdea55"