mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
backward compatible equality testing of immutables
- make non object equality tests non strict - this aligns with prior condition
This commit is contained in:
parent
10f77fdf1a
commit
73ff852648
@ -138,22 +138,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares `newValue` with `originalValue` for equality.
|
* Compares `newValue` with `originalValue` for equality.
|
||||||
* NOTES:
|
|
||||||
* * If `newValue` is a string or number, comparison is not strict
|
|
||||||
* * If `newValue` is anything else, comparison is strict
|
|
||||||
* @param {*} originalValue Original value
|
* @param {*} originalValue Original value
|
||||||
* @param {*} newValue New value
|
* @param {*} newValue New value
|
||||||
* @returns {boolean} true if originalValue equals newValue, otherwise false
|
* @returns {boolean} true if originalValue equals newValue, otherwise false
|
||||||
*/
|
*/
|
||||||
function isEqual(originalValue, newValue) {
|
function isEqual(originalValue, newValue) {
|
||||||
try {
|
try {
|
||||||
if (typeof newValue === "string" || typeof newValue === "number") {
|
if(originalValue == newValue) {
|
||||||
return originalValue == newValue;
|
return true;
|
||||||
}
|
|
||||||
if (typeof newValue === "boolean") {
|
|
||||||
return originalValue === newValue;
|
|
||||||
}
|
}
|
||||||
return JSON.stringify(originalValue) === JSON.stringify(newValue);
|
return JSON.stringify(originalValue) === JSON.stringify(newValue);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user