Skip to content

Commit

Permalink
Ajoute un polyfill pour requestIdleCallback
Browse files Browse the repository at this point in the history
fix #2793
  • Loading branch information
johangirod committed Sep 4, 2023
1 parent b4f794e commit 52ca8dd
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions site/source/entries/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,34 +154,34 @@
</div>

<script>
const isIframe = document.location.pathname.startsWith('/iframes/')
const isIframe = document.location.pathname.startsWith(/iframes/')
function getItem(key) {
try {
return window.localStorage.getItem(key)
} catch (error) {
if (error instanceof Error && error.name === 'SecurityError') {
if (error instanceof Error && error.name === SecurityError) {
// eslint-disable-next-line no-console
console.warn(
'[localStorage] Unable to set item due to security settings'
'[localStorage] Unable to set item due to security settings
)
}

return null
}
}

const darkMode = !isIframe && getItem('darkMode') === 'true'
const darkMode = !isIframe && getItem(darkMode) === true

if (darkMode) {
document.body.style.backgroundColor = '#0f172a'
document.body.style.backgroundColor = '#0f172a
}
</script>

<!-- USER AGENT DATA ATTRIBUTE -->
<script>
var b = document.documentElement
b.setAttribute('data-useragent', navigator.userAgent)
b.setAttribute(data-useragent, navigator.userAgent)
</script>

<script>
Expand All @@ -199,19 +199,19 @@
try {
const rawColor = new URLSearchParams(
document.location.search.substring(1)
).get('couleur')
).get(couleur)
const iframeColor = rawColor && parseColor(rawColor)
;[
document.documentElement,
...document.querySelectorAll('[data-js-color-element]'),
document.querySelectorAll([data-js-color-element]'),
].forEach((element) => {
element.style.setProperty(
'--COLOR_HUE',
iframeColor ? iframeColor[0] : '220deg'
'--COLOR_HUE,
iframeColor ? iframeColor[0] : 220deg
)
element.style.setProperty(
'--COLOR_SATURATION',
iframeColor ? iframeColor[1] + '%' : '100%'
'--COLOR_SATURATION,
iframeColor ? iframeColor[1] + '% : 100%
)
})
} catch (e) {
Expand All @@ -221,7 +221,7 @@

<script
crossorigin="anonymous"
src="https://polyfill.io/v3/polyfill.min.js?features=ResizeObserver%2CIntl.~locale.en%2CIntl.~locale.fr%2CString.prototype.replaceAll%2CObject.fromEntries%2CString.prototype.matchAll"
src="https://polyfill.io/v3/polyfill.min.js?features=ResizeObserver%2CIntl.~locale.en%2CIntl.~locale.fr%2CString.prototype.replaceAll%2CObject.fromEntries%2CString.prototype.matchAll%2CrequestIdleCallback"
></script>

<script type="module" src="{{ entry }}"></script>
Expand Down

0 comments on commit 52ca8dd

Please sign in to comment.