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") }