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
deploy / build-and-publish (push) Successful in 40s
This commit is contained in:
+10
-4
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user