diff --git a/lodash.src.js b/lodash.src.js index b76f896ec..6e82d62bb 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -2305,7 +2305,7 @@ length = path.length; while (object != null && ++index < length) { - var result = object = object[path[index]]; + var result = object = toObject(object)[path[index]]; } return result; } @@ -10021,7 +10021,7 @@ if (object != null && !isKey(path, object)) { path = toPath(path); object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); - result = object == null ? undefined : object[last(path)]; + result = object == null ? undefined : toObject(object)[last(path)]; } result = result === undefined ? defaultValue : result; } diff --git a/test/test.js b/test/test.js index 12318c788..624f726b9 100644 --- a/test/test.js +++ b/test/test.js @@ -13159,12 +13159,18 @@ }); }); - test('`_.' + methodName + '` should get characters of string indexes (test in IE < 9)', 4, function() { + test('`_.' + methodName + '` should get characters of string indexes (test in IE < 9)', 8, function() { _.each([1, [1]], function(path) { _.each(['xo', Object('xo')], function(string) { strictEqual(func(string, path), 'o'); }); }); + + _.each([{ 'a': 'xo' }, { 'a': Object('xo') }], function(object) { + _.each(['a[1]', ['a', '1']], function(path) { + strictEqual(func(object, path), 'o'); + }); + }); }); test('`_.' + methodName + '` should get a key over a path', 2, function() {