diff --git a/lodash.js b/lodash.js index a81f876c1..c8a9569e2 100644 --- a/lodash.js +++ b/lodash.js @@ -3757,7 +3757,7 @@ function basePick(object, props) { object = Object(object); return basePickBy(object, props, function(value, key) { - return key in object; + return hasIn(object, key); }); } @@ -3777,10 +3777,10 @@ while (++index < length) { var key = props[index], - value = object[key]; + value = get(object, key); if (predicate(value, key)) { - baseAssignValue(result, key, value); + set(result, key, value); } } return result; diff --git a/test/test.js b/test/test.js index ce4743707..3f177815e 100644 --- a/test/test.js +++ b/test/test.js @@ -16386,6 +16386,12 @@ assert.deepEqual(_.omit({ '0': 'a' }, 0), {}); }); + + QUnit.test('should work with deep properties', function(assert) { + assert.expect(1); + + assert.deepEqual(_.omit({ 'a': 1, 'b': { 'c': 2 } }, 'b.c'), { 'a': 1, 'b': {} }); + }); }()); /*--------------------------------------------------------------------------*/ @@ -17608,6 +17614,12 @@ assert.deepEqual(_.pick({ '0': 'a', '1': 'b' }, 0), { '0': 'a' }); }); + + QUnit.test('should work with deep properties', function(assert) { + assert.expect(1); + + assert.deepEqual(_.pick({ 'a': 1, 'b': { 'c': 2 } }, 'b.c'), { 'b': { 'c': 2 } }); + }); }()); /*--------------------------------------------------------------------------*/