From d97a56f64b9bb8c66319edf28336872bcb3102b7 Mon Sep 17 00:00:00 2001
From: Jazzzny <75343012+Jazzzny@users.noreply.github.com>
Date: Sat, 26 Oct 2024 13:55:56 -0400
Subject: [PATCH] Small changes for support for legacy browsers
- Remove prefers-color-scheme from light stylesheet
- Add fallback for addEventListener
---
django_ace/static/django_ace/widget.js | 12 +++++++++---
templates/base.html | 2 +-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/django_ace/static/django_ace/widget.js b/django_ace/static/django_ace/widget.js
index 7da6f32436..de517577fa 100644
--- a/django_ace/static/django_ace/widget.js
+++ b/django_ace/static/django_ace/widget.js
@@ -111,9 +111,15 @@
}
setEditorTheme(window.matchMedia('(prefers-color-scheme: dark)').matches);
- window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function(ev) {
- setEditorTheme(ev.matches);
- })
+ try {
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function(ev) {
+ setEditorTheme(ev.matches);
+ })
+ } catch (err) {
+ window.matchMedia('(prefers-color-scheme: dark)').addListener(function(ev) {
+ setEditorTheme(ev.matches);
+ })
+ }
}
}
if (wordwrap == "true") {
diff --git a/templates/base.html b/templates/base.html
index c866ab3568..113868bd30 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -49,7 +49,7 @@
{% if PREFERRED_STYLE_CSS is not none %}
{% else %}
-
+
{% endif %}
{% else %}