Skip to content

Commit 921e8c5

Browse files
wxiaoguangGiteaBot
authored andcommitted
Add minimum polyfill to support "relative-time-element" in PaleMoon (go-gitea#26575)
Close go-gitea#26525
1 parent 1cedf36 commit 921e8c5

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

web_src/js/webcomponents/polyfill.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
try {
2+
// some browsers like PaleMoon don't have full support for Intl.NumberFormat, so do the minimum polyfill to support "relative-time-element"
3+
// https://repo.palemoon.org/MoonchildProductions/UXP/issues/2289
4+
new Intl.NumberFormat('en', {style: 'unit', unit: 'minute'}).format(1);
5+
} catch {
6+
const intlNumberFormat = Intl.NumberFormat;
7+
Intl.NumberFormat = function(locales, options) {
8+
if (options.style === 'unit') {
9+
return {
10+
format(value) {
11+
return ` ${value} ${options.unit}`;
12+
}
13+
};
14+
}
15+
return intlNumberFormat(locales, options);
16+
};
17+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import '@webcomponents/custom-elements'; // polyfill for some browsers like Pale Moon
2+
import './polyfill.js';
3+
24
import '@github/relative-time-element';
35
import './GiteaOriginUrl.js';

0 commit comments

Comments
 (0)