Skip to content

Commit

Permalink
Fix: iOS 12.2 incompatible script (#19029)
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis authored Feb 21, 2025
1 parent 8e521ca commit 9869149
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion assets/js/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ function updateCssColors() {

// update colors on theme change
const darkModeMatcher = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)");
darkModeMatcher?.addEventListener("change", updateCssColors);
if (darkModeMatcher && darkModeMatcher.addEventListener) {
darkModeMatcher.addEventListener("change", updateCssColors);
}
// initialize colors
updateCssColors();
window.requestAnimationFrame(updateCssColors);
Expand Down
4 changes: 3 additions & 1 deletion assets/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ function updateMetaThemeForBackdrop() {
}

export function watchThemeChanges() {
darkModeMatcher?.addEventListener("change", updateTheme);
if (darkModeMatcher && darkModeMatcher.addEventListener) {
darkModeMatcher.addEventListener("change", updateTheme);
}
updateTheme();

// listen for modal backdrops
Expand Down

0 comments on commit 9869149

Please sign in to comment.