From fe3d86bf13a3f136fc26265dce84d738a7aa490c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 13 Jan 2016 21:20:05 -0800 Subject: [PATCH] Ensure `_.defaultsDeep` doesn't convert function properties to objects. [closes #1783] --- lodash.js | 4 +++- test/test.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index 8debf156e..707ca0bcc 100644 --- a/lodash.js +++ b/lodash.js @@ -5099,7 +5099,9 @@ stack.set(srcValue, objValue); baseMerge(objValue, srcValue, mergeDefaults, stack); } - return objValue === undefined ? baseClone(srcValue) : objValue; + return objValue === undefined + ? baseClone(srcValue, undefined, undefined, key, object) + : objValue; } /** diff --git a/test/test.js b/test/test.js index b2278a9a5..19e192e0a 100644 --- a/test/test.js +++ b/test/test.js @@ -3998,6 +3998,16 @@ assert.strictEqual(actual.a.b, null); }); + QUnit.test('should not convert function properties to objects', function(assert) { + assert.expect(2); + + var actual = _.defaultsDeep({}, { 'a': noop }); + assert.strictEqual(actual.a, noop); + + actual = _.defaultsDeep({}, { 'a': { 'b': noop } }); + assert.strictEqual(actual.a.b, noop); + }); + QUnit.test('should overwrite `undefined` values', function(assert) { assert.expect(1);