From 93c902cc78172985d3dab213a6800bf0b13a23b1 Mon Sep 17 00:00:00 2001 From: GGodPL <46885632+GGodPL@users.noreply.github.com> Date: Tue, 1 Aug 2023 22:46:07 +0200 Subject: [PATCH] elementsManager fix --- mods/elementsManager.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mods/elementsManager.js b/mods/elementsManager.js index 194e1285..c067222a 100644 --- a/mods/elementsManager.js +++ b/mods/elementsManager.js @@ -397,6 +397,7 @@ if (enabledMods.includes(mod)) { } const parseColor = (colorString) => { + if (typeof colorString != "string") return "#ffffff"; if (colorString.startsWith("rgb(")) { const color = colorString.replace("rgb(", "").replace(")", ""); return `#${color.split(",").map(a => parseInt(a).toString(16)).join("")}`; @@ -603,7 +604,7 @@ if (enabledMods.includes(mod)) { el.onchange = (ev) => { const elementData = Storage.get("newElement", {}); if (prop.type == "number") elementData[prop.name] = parseFloat(ev.target.value); - else if (prop.type == "color" || prop.type[0] == "color") elementData[prop.name] = hexToRGB(ev.target.value); + else if (prop.type == "color" || prop.type[0] == "color") elementData[prop.name] = parseColor(ev.target.value); else if (prop.type == "string") elementData[prop.name] = ev.target.value; Storage.set("newElement", elementData); } @@ -984,11 +985,9 @@ if (enabledMods.includes(mod)) { elementData[prop.name] = "POWDER_OLD"; } else { el.setAttribute("value", default_[prop.type]); - elementData[prop.name] = default_[prop.type]; } if (prop.type == "boolean") { el.setAttribute("state", "0") - elementData[prop.name] = false; } } }