-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
ViewTransition - Identifier 'theme' has already been declared #8466
Comments
Exactly the same error here with ViewTransitionI have a blog with just a homepage After set the
Also, this is my component, nothing fancy neither
The weird thing is that if I delete the
The unique place in the whole codebase where i use I'm assuming they are related ;P |
Fixed after moving both I tried to make it work on-component but its not an option apparently |
It is NOT werid. |
I think the issue here is that if the script is within the body we do not prevent re-execution, but do so for scripts in the head. Should be easy enough to fix. |
I am having the same issue now when using view transitions with Astro version 4.2.3. It does not seem to matter if I use is:inline or not.
|
Thanks a lot @OliverSpeir , indeed this does the trick. It works with plain <script> but not with either type="text/javascript" or is:inline. |
It is true that scripts without any properties aren't re-executed as they become module scripts referenced from the @morja, whatever your original issue was: scripts with Maybe we can investigate further on discord #support or you open another issue for your case with a minimal reproduction? |
For posterity sake I was wrong about type="text/javascript" having anything to do with this! |
TIL: The check whether an inline script from the new page shouldn't be re-executed only compares against |
Hi, I imagine people here know how to fix the error, but for new visitors here is my solution. When I use ViewTransitions component I don't get the scripts after going to another page. Then I found this https://docs.astro.build/en/tutorials/add-view-transitions/ then I did this
I just wrapped my code with that event and it already works. |
Hi @xArrietAx, thank you for sharing this and helping others! Further information on how to rerun code after view transitions can also be found here |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using ViewTransition on global layout with a astro component that have inline script, it somehow logged a syntax error every time we traverse a page and the inline script did not worked.
I search in the issues list and I found old similar case but with different root cause #3643
What's the expected result?
Inline script inside astro component worked and no syntax error being logged.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-wqkwwm
Participation
The text was updated successfully, but these errors were encountered: