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 {
public formatValue(val: any): any {
const opt = this.element.querySelector(`option[value="${val}"]`) || this.element.querySelector("option[selected]")
if (opt) {
return realType(opt.getAttribute("value") || "")
public formatValue(value: any): any {
if (typeof value === "undefined") {
const opt: HTMLOptionElement = this.element.querySelector("option[selected]")
if (opt) {
return opt.value
}
}
return undefined
return realType(value)
}
public static identity: InputIdentity = {