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

fix(@astrojs/partytown): prevent crashes when View Transitions are enabled #11083

Merged
merged 3 commits into from
Jun 10, 2024

Conversation

V3RON
Copy link
Contributor

@V3RON V3RON commented May 17, 2024

Changes

This pull request intend to resolve the incompatibility of Partytown integration and View Transitions.

The Partytown snippet is supposed to be loaded only once, but when the View Transitions API gets activated, the <script> element containing this snippet is recreated on every transition. It has been changed and now it's executed only once.

Under certain conditions, Partytown may need an <iframe> element to be present on the page. When a view transition happens, this <iframe> is removed from the DOM. There has been a change added, which will move <iframe> element from the old document to the new one. The side-effect is all Partytown scripts will get re-executed. That behavior is aligned with other frameworks like Nuxt.

Closes #11033

Testing

There is no testing suite present for Partytown. I believe we should work on implementing one, but that's probably out of scope for this pull request.

Docs

I'm not sure if docs update is needed, because Partytown never really worked with View Transitions 😅 On the other hand, it's worth mentioning that scripts will get re-executed on each transition.

/cc @withastro/maintainers-docs for feedback!

Copy link

changeset-bot bot commented May 17, 2024

🦋 Changeset detected

Latest commit: 5f44ee5

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label May 17, 2024
@dsegovia90
Copy link

Anything we can do to move this along? Looking forward to using it on one of our projects.

@ematipico ematipico requested a review from martrapp June 10, 2024 10:16
@ematipico ematipico merged commit 416c4ac into withastro:main Jun 10, 2024
13 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Partytown scripts break ViewTransition
4 participants