diff --git a/lodash.js b/lodash.js index 8d93d7ea0..be3c7c669 100644 --- a/lodash.js +++ b/lodash.js @@ -5632,8 +5632,8 @@ * @param {string} key The key of the property to inspect. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. */ - function customOmitClone(value, key) { - return (key !== undefined && isPlainObject(value)) ? undefined : value; + function customOmitClone(value) { + return isPlainObject(value) ? undefined : value; } /** diff --git a/test/test.js b/test/test.js index 9d34d4389..c75e2e923 100644 --- a/test/test.js +++ b/test/test.js @@ -16450,6 +16450,16 @@ assert.deepEqual(_.omit(object, args), { 'b': 2, 'd': 4 }); }); + + QUnit.test('should not mutate `object`', function(assert) { + assert.expect(4); + + lodashStable.each(['a', ['a'], 'a.b', ['a.b']], function(path) { + var object = { 'a': { 'b': 2 } }; + _.omit(object, path); + assert.deepEqual(object, { 'a': { 'b': 2 } }); + }); + }); }()); /*--------------------------------------------------------------------------*/