From 44762c6e727843540f0f061c8b33a4ff8e67c1ba Mon Sep 17 00:00:00 2001 From: Avior Date: Mon, 9 Dec 2019 14:14:01 +0100 Subject: [PATCH] fix Select input not setting the correct value Signed-off-by: Avior --- src/modules/SelectInput.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/modules/SelectInput.ts b/src/modules/SelectInput.ts index ca7f0c2..fb6c71e 100644 --- a/src/modules/SelectInput.ts +++ b/src/modules/SelectInput.ts @@ -10,25 +10,16 @@ import { realType } from '../Functions'; export default class SelectInput extends DefaultInput { public setValue(value: any) { - value = realType(value) - let opt:HTMLOptionElement|undefined = this.element.querySelector(`option[value="${value}"]`) || undefined - if (opt) { - this.element.value = value - return - } - opt = this.element.querySelector("option[selected]") || undefined - if (opt) { - this.element.value = opt.value - } + this.element.value = this.formatValue(value) } public formatValue(value: any): any { if (typeof value !== "undefined" && value !== "") { return realType(value) } - const opt: HTMLOptionElement|undefined = this.element.querySelector("option[selected]") || undefined + const opt = this.element.querySelector("option[selected]") || undefined if (opt) { - return opt.value + return (opt as HTMLOptionElement).value } throw Error(":O it should never come here") }