1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Allow RED.settings.set to replace string property with object property

This commit is contained in:
Nick O'Leary 2021-05-25 21:02:14 +01:00
parent bc17ebd90e
commit 468ef7ecff
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -36,7 +36,15 @@ function extend(target, source) {
} else {
// Object
if (target.hasOwnProperty(keys[i])) {
target[keys[i]] = extend(target[keys[i]],value);
// Target property exists. Need to handle the case
// where the existing property is a string/number/boolean
// and is being replaced wholesale.
var targetType = typeof target[keys[i]];
if (targetType === 'string' || targetType === 'number' || targetType === 'boolean') {
target[keys[i]] = value;
} else {
target[keys[i]] = extend(target[keys[i]],value);
}
} else {
target[keys[i]] = value;
}