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: stylesheet loading #57

Merged
merged 3 commits into from
Nov 14, 2024
Merged

fix: stylesheet loading #57

merged 3 commits into from
Nov 14, 2024

Conversation

benjaminrobinet
Copy link
Contributor

@benjaminrobinet benjaminrobinet commented Nov 13, 2024

Description

This PR aims to fix the loading of Stylesheets.
Currently they are cloned before inserted to the current page, but the one that is awaited to be loaded is not the cloned one. So it never loads.
I am fixing this by returning the newly cloned one.

It also fix the infinite loop / memory leak in the waitForStylesheet function that occurs when the provided timeout is elapsed and the stylesheet never loads.

Checks

  • The PR is submitted to the master branch
  • The code was linted before pushing (npm run lint)
  • All tests are passing (npm run test)
  • New or updated tests are included
  • The documentation was updated as required

@benjaminrobinet benjaminrobinet marked this pull request as ready for review November 13, 2024 18:13
@benjaminrobinet
Copy link
Contributor Author

Special thanks to @Nam-Hai for helping me on this.

@daun
Copy link
Member

daun commented Nov 14, 2024

Welcome and thanks for contributing. This looks great! Never realized this was broken in the first place. Tests are passing, but I'll give this a try in our playground and report back.

@daun
Copy link
Member

daun commented Nov 14, 2024

Works great, thanks a lot! I realize now why we never caught this. We were testing locally with a delayed stylesheet that was delayed by the same amount as the timeout (😭), so the stylesheet and timeout would trigger at the same time and we just assumed it was the stylesheet when it was the timeout triggering things. We'll try to come up with a set of matching tests.

@daun daun merged commit 1271d31 into swup:master Nov 14, 2024
1 check passed
@benjaminrobinet
Copy link
Contributor Author

I was so struggling with this issue hahaha, was a pleasure to fix it.
I like how Swup handles the page transitions, thanks for your work !

@daun
Copy link
Member

daun commented Nov 14, 2024

Released as 2.3.1 🥬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants