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.
|
||||
* 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user