mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Add test for customizer results of NaN.
This commit is contained in:
@@ -1695,7 +1695,8 @@
|
|||||||
var value = object[key],
|
var value = object[key],
|
||||||
result = customizer(value, source[key], key, object, source);
|
result = customizer(value, source[key], key, object, source);
|
||||||
|
|
||||||
if (result !== value || (typeof value == 'undefined' && !(key in object))) {
|
if ((result === result ? result !== value : value === value) ||
|
||||||
|
(typeof value == 'undefined' && !(key in object))) {
|
||||||
object[key] = result;
|
object[key] = result;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2496,7 +2497,8 @@
|
|||||||
if (isCommon) {
|
if (isCommon) {
|
||||||
result = srcValue;
|
result = srcValue;
|
||||||
}
|
}
|
||||||
if ((isSrcArr || typeof result != 'undefined') && (isCommon || result !== value)) {
|
if ((isSrcArr || typeof result != 'undefined') &&
|
||||||
|
(isCommon || (result === result ? result !== value : value === value))) {
|
||||||
object[key] = result;
|
object[key] = result;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -2528,7 +2530,7 @@
|
|||||||
// Recursively merge objects and arrays (susceptible to call stack limits).
|
// Recursively merge objects and arrays (susceptible to call stack limits).
|
||||||
if (isCommon) {
|
if (isCommon) {
|
||||||
object[key] = baseMerge(result, srcValue, customizer, stackA, stackB);
|
object[key] = baseMerge(result, srcValue, customizer, stackA, stackB);
|
||||||
} else if (result !== value) {
|
} else if (result === result ? result !== value : value === value) {
|
||||||
object[key] = result;
|
object[key] = result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4796,8 +4796,8 @@
|
|||||||
deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3 });
|
deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3 });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('`_.' + methodName + '` should not assign the `customizer` result if it is the same as the destination value', 3, function() {
|
test('`_.' + methodName + '` should not assign the `customizer` result if it is the same as the destination value', 4, function() {
|
||||||
_.each(['a', ['a'], { 'a': 1 }], function(value) {
|
_.each(['a', ['a'], { 'a': 1 }, NaN], function(value) {
|
||||||
if (defineProperty) {
|
if (defineProperty) {
|
||||||
var object = {},
|
var object = {},
|
||||||
pass = true;
|
pass = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user