From 33995eb287385b493be3197f113239ba006d6f41 Mon Sep 17 00:00:00 2001 From: Christian7573 Date: Fri, 4 Jun 2021 21:32:15 -0500 Subject: [PATCH] Enforce min and max manually, apparently the input el doesn't do this --- src/assets/xterm_config/functionality.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/assets/xterm_config/functionality.js b/src/assets/xterm_config/functionality.js index cadc65e..61c34e8 100644 --- a/src/assets/xterm_config/functionality.js +++ b/src/assets/xterm_config/functionality.js @@ -4,7 +4,13 @@ function optionEnumGet() { return this.el.querySelector("select").value; } function optionEnumSet(value) { this.el.querySelector("select").value = value; } function optionBoolGet() { return this.el.querySelector("input").checked; } function optionBoolSet(value) { this.el.querySelector("input").checked = value; } -function optionNumberGet() { return (this.float === true ? parseFloat : parseInt)(this.el.querySelector("input").value); } +function optionNumberGet() { + let value = (this.float === true ? parseFloat : parseInt)(this.el.querySelector("input").value); + if (Number.isNaN(value) || typeof value !== "number") value = 0; + if (typeof this.min === "number") value = Math.max(value, this.min); + if (typeof this.max === "number") value = Math.min(value, this.max); + return value; +} function optionNumberSet(value) { this.el.querySelector("input").value = value; } const allOptions = [];