mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Ensure baseGet returns undefined and not null. [closes #1136]
This commit is contained in:
@@ -2305,9 +2305,9 @@
|
|||||||
length = path.length;
|
length = path.length;
|
||||||
|
|
||||||
while (object != null && ++index < length) {
|
while (object != null && ++index < length) {
|
||||||
var result = object = toObject(object)[path[index]];
|
object = toObject(object)[path[index]];
|
||||||
}
|
}
|
||||||
return result;
|
return (index && index == length) ? object : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13222,7 +13222,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('`_.' + methodName + '` should return `undefined` if parts of `path` are missing', 2, function() {
|
test('`_.' + methodName + '` should return `undefined` if parts of `path` are missing', 2, function() {
|
||||||
var object = {};
|
var object = { 'a': [, null] };
|
||||||
|
|
||||||
_.each(['a[1].b.c', ['a', '1', 'b', 'c']], function(path) {
|
_.each(['a[1].b.c', ['a', '1', 'b', 'c']], function(path) {
|
||||||
strictEqual(func(object, path), undefined);
|
strictEqual(func(object, path), undefined);
|
||||||
|
|||||||
Reference in New Issue
Block a user