Fix the language switcher: inline onchange died on 'URL is not a constructor' (document.URL shadows the URL constructor in inline-handler scope); moved to a delegated change listener that assigns location.href directly
deploy / build-and-publish (push) Successful in 40s

This commit is contained in:
Keith
2026-11-22 15:07:49 +01:00
parent 3d176192aa
commit 5e299f67b2
+10 -4
View File
@@ -205,10 +205,7 @@ const hasForm = isAudiencePage;
))}
<label class="switcher">
<span aria-hidden="true">{strings.switcher_label}</span>
<select
aria-label={strings.lang_label}
onchange={`const u=new URL(this.value, location.origin); location.href = u.href;`}
>
<select aria-label={strings.lang_label}>
{alternates.map((a) => (
<option value={pageUrl(a.code, a.id)} selected={a.code === locale}>
{localeByCode(a.code)?.name ?? a.code}
@@ -379,6 +376,15 @@ const hasForm = isAudiencePage;
window.umami && window.umami.track(el.dataset.umamiEvent, { selected: !!el.checked });
} catch {}
});
// Language switcher: the option values are absolute URLs, so a plain
// assignment navigates. (Not an inline onchange attribute: there
// `document.URL` shadows the URL constructor and the handler dies.)
const langSelect = document.querySelector(".switcher select");
if (langSelect) {
langSelect.addEventListener("change", (e) => {
location.href = e.target.value;
});
}
// Pricing flow: pick a model first, then the four questions appear
// one at a time, each showing only the selected model's price
// ranges. Switching model clears previous answers.