diff --git a/lodash.src.js b/lodash.src.js index 5876702cf..81dcf70bc 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -9820,7 +9820,11 @@ * // => 'busy' */ function result(object, path, defaultValue) { - var value = object == null ? undefined : getProperty(object, path); + path = toPath(path); + if (path.length > 1) { + object = getPath(object, dropRight(path)); + } + var value = getProperty(object, last(path)); if (typeof value == 'undefined') { value = defaultValue; } diff --git a/test/test.js b/test/test.js index d71befd8b..bbc3a5838 100644 --- a/test/test.js +++ b/test/test.js @@ -12497,6 +12497,14 @@ var actual = _.result(object, 'd', object.c); strictEqual(actual, 1); }); + + test('should call deep property method with correct context', 1, function() { + var value = { + 'deep': object + }; + + strictEqual(_.result(value, ['deep', 'c']), 1); + }) }()); /*--------------------------------------------------------------------------*/