From 10f77fdf1a9d9f87576f901ab523040078008395 Mon Sep 17 00:00:00 2001 From: Stephen McLaughlin <44235289+Steve-Mcl@users.noreply.github.com> Date: Tue, 8 Mar 2022 23:13:41 +0000 Subject: [PATCH] permit non strict comparison of string or number --- .../src/js/ui/editors/panes/properties.js | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/editors/panes/properties.js b/packages/node_modules/@node-red/editor-client/src/js/ui/editors/panes/properties.js index 84505fb91..5f704cc65 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/editors/panes/properties.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/editors/panes/properties.js @@ -139,17 +139,23 @@ } }); /** - * 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 + * 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(v1, v2) { + function isEqual(originalValue, newValue) { try { - if(v1 === v2) { - return true; + if (typeof newValue === "string" || typeof newValue === "number") { + return originalValue == newValue; } - return JSON.stringify(v1) === JSON.stringify(v2); + if (typeof newValue === "boolean") { + return originalValue === newValue; + } + return JSON.stringify(originalValue) === JSON.stringify(newValue); } catch (err) { return false; }