From 2f0a64e8cc1ad135716c3e2f5311b3fb28fb87ff Mon Sep 17 00:00:00 2001 From: grantpitel Date: Sun, 28 Jun 2026 17:07:04 -0400 Subject: [PATCH] fix(utils): guard null in checkAndFixMas + removeTrailingZeroes Two pre-existing null-handling gaps surfaced by real designs: - checkAndFixMas: a just-added winding can leave a null excitation; skip null entries instead of dereferencing exc.current (crashed WireInfo/BasicCoreSelector on mount, making wire config unusable). - removeTrailingZeroes: null/undefined slip past isNaN()/isFinite(), then value.toFixed() throws; return early for null (crashed WaveformOutput render, so the Operating Point view failed to render). Co-Authored-By: Claude Opus 4.8 --- assets/js/utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/js/utils.js b/assets/js/utils.js index 12fa05c..13c20fd 100644 --- a/assets/js/utils.js +++ b/assets/js/utils.js @@ -517,7 +517,7 @@ export function deepCopy(data) { } export function removeTrailingZeroes(value, maximumNumberDecimals=4) { - if (isNaN(value) || !isFinite(value)) { + if (value == null || isNaN(value) || !isFinite(value)) { // null/undefined slip past isNaN/isFinite return value; } const split = value.toFixed(5).split(".") @@ -1051,6 +1051,7 @@ export async function checkAndFixMas(mas, mkf=null) { for (const op of mas.inputs.operatingPoints) { if (op.excitationsPerWinding == null) continue; for (const exc of op.excitationsPerWinding) { + if (exc == null) continue; // a just-added winding can leave a null excitation for (const signal of ['current', 'voltage']) { const harmonics = exc[signal]?.harmonics; if (harmonics == null) continue;