Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the page theme doesn’t update dark during preview #1339

Open
mbostock opened this issue May 14, 2024 · 2 comments · May be fixed by #1638
Open

Changing the page theme doesn’t update dark during preview #1339

mbostock opened this issue May 14, 2024 · 2 comments · May be fixed by #1638
Labels
bug Something isn’t working

Comments

@mbostock
Copy link
Member

E.g., editing the front matter from

---
theme: dark
---

to

---
theme: light
---

doesn’t change the value of dark until reload.

@mbostock mbostock added the bug Something isn’t working label May 14, 2024
@Fil
Copy link
Contributor

Fil commented May 14, 2024

True! There was this todo comment in #1018:

// TODO: in preview, also watch for changes in the theme meta.

@mbostock
Copy link
Member Author

This is a bit tricky to do because:

  • Any stylesheet could, in theory, change the computed value of color-scheme.
  • The color-scheme could 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.

Fil added a commit that referenced this issue Sep 4, 2024
@Fil Fil linked a pull request Sep 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants