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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user