Fix relative-time error and improve global error handler (#37241)

1. Fixes: #37239
2. Enhance global error message to show stack trace on click

---------

Signed-off-by: silverwind <me@silverwind.io>
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-04-21 09:53:19 +02:00
committed by GitHub
parent 3db3127655
commit caff989f34
7 changed files with 104 additions and 31 deletions
+5 -5
View File
@@ -258,13 +258,13 @@ class RelativeTime extends HTMLElement {
}
get #lang(): string {
const lang = this.closest('[lang]')?.getAttribute('lang');
if (lang) {
for (const candidate of [this.closest('[lang]')?.getAttribute('lang'), navigator.language]) {
if (!candidate) continue;
try {
return new Intl.Locale(lang).toString();
} catch { /* invalid locale, fall through */ }
return String(new Intl.Locale(candidate));
} catch {}
}
return navigator.language ?? 'en';
return 'en';
}
get second(): 'numeric' | '2-digit' | undefined {