Updated SelectInput

This commit is contained in:
Florian Bouillon 2019-11-15 11:11:56 +01:00
parent d55730bedd
commit 78e572faf3
No known key found for this signature in database
GPG Key ID: B143FF27EF555D16

View File

@ -9,12 +9,14 @@ import { realType } from '../Functions';
*/ */
export default class SelectInput extends DefaultInput { export default class SelectInput extends DefaultInput {
public formatValue(val: any): any { public formatValue(value: any): any {
const opt = this.element.querySelector(`option[value="${val}"]`) || this.element.querySelector("option[selected]") if (typeof value === "undefined") {
if (opt) { const opt: HTMLOptionElement = this.element.querySelector("option[selected]")
return realType(opt.getAttribute("value") || "") if (opt) {
return opt.value
}
} }
return undefined return realType(value)
} }
public static identity: InputIdentity = { public static identity: InputIdentity = {