1
0
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:
Stephen McLaughlin 2022-03-10 11:22:59 +00:00 committed by GitHub
parent 10f77fdf1a
commit 73ff852648
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -138,22 +138,17 @@
}
}
});
/**
* 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 {*} newValue New value
* @returns {boolean} true if originalValue equals newValue, otherwise false
*/
function isEqual(originalValue, newValue) {
function isEqual(originalValue, newValue) {
try {
if (typeof newValue === "string" || typeof newValue === "number") {
return originalValue == newValue;
}
if (typeof newValue === "boolean") {
return originalValue === newValue;
if(originalValue == newValue) {
return true;
}
return JSON.stringify(originalValue) === JSON.stringify(newValue);
} catch (err) {