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

handle errors by circ refs, undefined, BigInt etc

This commit is contained in:
Steve-Mcl 2022-03-08 14:20:12 +00:00
parent a49927f173
commit 84a9cf7adf

View File

@ -107,7 +107,7 @@
newValue = ""; newValue = "";
} }
} }
if (!JSON.stringify(node[d]) === JSON.stringify(newValue)) { if (!isEqual(node[d], newValue)) {
if (node._def.defaults[d].type) { if (node._def.defaults[d].type) {
// Change to a related config node // Change to a related config node
var configNode = RED.nodes.node(node[d]); var configNode = RED.nodes.node(node[d]);
@ -138,6 +138,22 @@
} }
} }
}); });
/**
* Compares `v1` with `v2` for equality
* @param {*} v1 variable 1
* @param {*} v2 variable 2
* @returns {boolean} true if variable 1 equals variable 2, otherwise false
*/
function isEqual(v1, v2) {
try {
if(v1 === v2) {
return true;
}
return JSON.stringify(v1) === JSON.stringify(v2);
} catch (err) {
return false;
}
}
/** /**
* Update the node credentials from the edit form * Update the node credentials from the edit form