fix(playground): gracefully fallback to JavaScript if the select info is undefined

This commit is contained in:
Amaan Qureshi 2024-12-27 17:08:49 -05:00
parent 9228a31f94
commit 48fe030bdd
No known key found for this signature in database
GPG key ID: E67890ADC4227273

View file

@ -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) => {