Fix safari 13 crash
parent
e7c957ab18
commit
1aef3657c0
|
@ -46,9 +46,18 @@ export const DarkModeProvider: React.FC = ({ children }) => {
|
|||
setDarkMode(e.matches)
|
||||
}
|
||||
const matchDarkMode = window.matchMedia('(prefers-color-scheme: dark)')
|
||||
matchDarkMode.addEventListener('change', onDarkModeChange)
|
||||
|
||||
return () => matchDarkMode.removeEventListener('change', onDarkModeChange)
|
||||
// safari 13 doesn't have addEventListener
|
||||
matchDarkMode.addEventListener
|
||||
? matchDarkMode.addEventListener('change', onDarkModeChange)
|
||||
: matchDarkMode.addListener(onDarkModeChange)
|
||||
|
||||
return () => {
|
||||
// safari 13 doesn't have removeEventListener
|
||||
matchDarkMode.removeEventListener
|
||||
? matchDarkMode.removeEventListener('change', onDarkModeChange)
|
||||
: matchDarkMode.removeListener(onDarkModeChange)
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
|
|
|
@ -223,7 +223,7 @@
|
|||
<script>
|
||||
// Set the main colors from the provided customization in the URL We do it
|
||||
// before loading the whole JS bundle to avoid a UI flash. cf. #1786
|
||||
const parseColor = (rawColor) => {
|
||||
function parseColor(rawColor) {
|
||||
try {
|
||||
return JSON.parse(decodeURIComponent(rawColor))
|
||||
} catch (error) {
|
||||
|
@ -233,10 +233,10 @@
|
|||
}
|
||||
}
|
||||
try {
|
||||
let rawColor = new URLSearchParams(
|
||||
const rawColor = new URLSearchParams(
|
||||
document.location.search.substring(1)
|
||||
).get('couleur')
|
||||
let iframeColor = rawColor && parseColor(rawColor)
|
||||
const iframeColor = rawColor && parseColor(rawColor)
|
||||
;[
|
||||
document.documentElement,
|
||||
...document.querySelectorAll('[data-js-color-element]'),
|
||||
|
|
Loading…
Reference in New Issue