mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Ensure _.set and _.setWith don't assign a value if it's the same as the destination value.
This commit is contained in:
13
lodash.js
13
lodash.js
@@ -2511,18 +2511,15 @@
|
||||
while (nested != null && ++index < length) {
|
||||
var key = path[index];
|
||||
if (isObject(nested)) {
|
||||
if (index == lastIndex) {
|
||||
nested[key] = value;
|
||||
}
|
||||
else {
|
||||
var oldValue = nested[key],
|
||||
newValue = customizer ? customizer(oldValue, key, nested) : undefined;
|
||||
|
||||
var newValue = value;
|
||||
if (index != lastIndex) {
|
||||
var oldValue = nested[key];
|
||||
newValue = customizer ? customizer(oldValue, key, nested) : undefined;
|
||||
if (newValue === undefined) {
|
||||
newValue = oldValue == null ? (isIndex(path[index + 1]) ? [] : {}) : oldValue;
|
||||
}
|
||||
assignValue(nested, key, newValue);
|
||||
}
|
||||
assignValue(nested, key, newValue);
|
||||
}
|
||||
nested = nested[key];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user