1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-06-30 02:05:57 -04:00

use safer CSS.insertRule instead of innerHTML for dark mode transition hack

This commit is contained in:
2021-09-24 11:22:08 -04:00
parent 081864d091
commit d5088e1982
+4 -3
View File
@@ -2,13 +2,14 @@ import { init as initDarkMode } from "dark-mode-switcheroo";
// HACK: disable theme transition until user's preference is auto-restored (1/2) // HACK: disable theme transition until user's preference is auto-restored (1/2)
const disableTransitionCSSHack = document.createElement("style"); const disableTransitionCSSHack = document.createElement("style");
disableTransitionCSSHack.innerHTML = ` document.head.appendChild(disableTransitionCSSHack);
disableTransitionCSSHack.sheet.insertRule(`
*, *,
::before, ::before,
::after { ::after {
transition-property: none !important; transition-property: none !important;
}`; }
document.head.appendChild(disableTransitionCSSHack); `);
initDarkMode({ initDarkMode({
toggle: document.querySelector(".dark-mode-toggle"), toggle: document.querySelector(".dark-mode-toggle"),