clock: use addListener for media query
Previously, we used addEventListener, which was returned by the
media query as an inheritance from the window object.
Safari doesn't support this, but it, and all browsers,
support an alias that uses function-based checks.
This commit uses that alias.
@@ -18,20 +18,17 @@ let text = "#000000", background = "#ffffff";
let dark = window.matchMedia('(prefers-color-scheme: dark)');
+function darkColors(dark) {
if (dark.matches) {
text = "#7f7f7f";
background = "#333";
-}
-
-dark.addEventListener("change", (e) => {
- if (e.matches) {
- text = "#7f7f7f";
- background = "#333";
} else {
text = "#000000";
background = "#ffffff"
}
-})
+ }
+
+dark.addListener(darkColors)
const toRelativeTime = (date, referenceTime, unit) => moment(date)
