Add support for pre-selected options
This commit is contained in:
parent
61facdbfb9
commit
2f2db6edc6
1 changed files with 3 additions and 0 deletions
|
@ -298,6 +298,9 @@ export class BetterSelect extends HTMLElement {
|
||||||
this.list.replaceChildren()
|
this.list.replaceChildren()
|
||||||
for (const option of this.options) {
|
for (const option of this.options) {
|
||||||
this.list.append(f`<li tabindex="0" part="item" data-value="${option.value}">${option.innerText}</li>`)
|
this.list.append(f`<li tabindex="0" part="item" data-value="${option.value}">${option.innerText}</li>`)
|
||||||
|
if (option.selected) {
|
||||||
|
this.value = option.value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue