framework
framework copied to clipboard
Changing the page theme doesn’t update dark during preview
trafficstars
E.g., editing the front matter from
---
theme: dark
---
to
---
theme: light
---
doesn’t change the value of dark until reload.
True! There was this todo comment in #1018:
// TODO: in preview, also watch for changes in the theme meta.
This is a bit tricky to do because:
- Any stylesheet could, in theory, change the computed value of
color-scheme. - The
color-schemecould even be defined dynamically! - When the theme changes, new stylesheets are loaded asynchronously.
- When a LINK element’s href attribute is changed, it does not emit a load event.
It would be possible to detect when the (Framework-specified) stylesheet changes, and force the replacement of LINK elements rather than updating the href attribute, and then listen for load events on the added stylesheets (and check the removed ones), and finally re-evaluate the dark built-in. But it’s a bit of work, and still imperfect. Maybe this is just an acceptable bug as-is.