()
| 19 | if (theme === "system") { |
| 20 | const mq = window.matchMedia("(prefers-color-scheme: dark)"); |
| 21 | const apply = () => { |
| 22 | root.classList.remove("light", "dark"); |
| 23 | root.classList.add(mq.matches ? "dark" : "light"); |
| 24 | }; |
| 25 | apply(); |
| 26 | mq.addEventListener("change", apply); |
| 27 | return () => mq.removeEventListener("change", apply); |