fix(playground): gracefully fallback to JavaScript if the select info is undefined
This commit is contained in:
parent
9228a31f94
commit
48fe030bdd
1 changed files with 5 additions and 1 deletions
|
|
@ -29,7 +29,11 @@ function initializeCustomSelect({ initialValue = null, addListeners = false }) {
|
|||
if (initialValue) {
|
||||
select.value = initialValue;
|
||||
}
|
||||
selectedValue.textContent = select.options[select.selectedIndex].text;
|
||||
if (select.selectedIndex >= 0 && select.options[select.selectedIndex]) {
|
||||
selectedValue.textContent = select.options[select.selectedIndex].text;
|
||||
} else {
|
||||
selectedValue.textContent = 'JavaScript';
|
||||
}
|
||||
|
||||
if (addListeners) {
|
||||
button.addEventListener('click', (e) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue