{
if (!customElements.get('country-selector')) {
class CountrySelector extends customElements.get('custom-select') {
constructor() {
super();
this.loaded = false;
}
async showListbox() {
if (this.loaded) {
super.showListbox();
return;
}
this.button.classList.add('is-loading');
this.button.setAttribute('aria-disabled', 'true');
try {
const response = await fetch('?section_id=country-selector');
if (!response.ok) throw new Error(response.status);
const tmpl = document.createElement('template');
tmpl.innerHTML = await response.text();
const el = tmpl.content.querySelector('.custom-select__listbox');
this.listbox.innerHTML = el.innerHTML;
this.options = this.querySelectorAll('.custom-select__option');
this.loaded = true;
} catch {
this.listbox.innerHTML = 'Errore durante il recupero dei Paesi, riprova. ';
} finally {
super.showListbox();
this.button.classList.remove('is-loading');
this.button.setAttribute('aria-disabled', 'false');
}
}
setButtonWidth() {
return;
}
}
customElements.define('country-selector', CountrySelector);
}
});
© 2026 Wanderings. All Right Reserved
