Skip to content

View Transition resets html attributes #7765

@florian-lefebvre

Description

@florian-lefebvre

What version of astro are you using?

^2.9.1

Are you using an SSR adapter? If so, which one?

Vercel

What package manager are you using?

npm

What operating system are you using?

Windows

What browser are you using?

Brave

Describe the Bug

I have a script that toggles the .dark class on the html element. However, using view transitions, the html class is reset to its original state (ie. class specified in the layout) but the script is not re-run.

To reproduce:

  1. The page background will be red if your os is in dark mode
  2. navigate to another page, the background will be white again

What's the expected result?

I'd expect one of the following:

  1. html attributes are not reset to default because scripts are not re-run
  2. scripts re-run

I think 1. makes more sense to avoid flashes

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-8a4stc

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

Labels

- P3: minor bugAn edge case that only affects very specific usage (priority)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions