Allow setting value to undefined

This commit is contained in:
Talia 2025-01-27 16:08:37 +01:00
parent f55e420cbc
commit 6c3db0456e

View file

@ -385,12 +385,16 @@ export class BetterSelect extends HTMLElement {
get value() { return this.#value.value }
set value(value) {
for (const option of this.options) {
if (value === undefined) {
this.clear()
} else {
for (const option of Array.from(this.options)) {
if (option.value === String(value)) {
this.setValue(option.value, option.innerText)
return
}
}
}
throw `No option with value ${value}`
}