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: Add or execute DOMContentLoaded events based on document state #65

Open
wants to merge 3 commits into
base: 4.x
Choose a base branch
from

Conversation

AylenHoz
Copy link
Contributor

@AylenHoz AylenHoz commented Feb 13, 2025

🔗 Linked issue

closes #66

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

In this commit, the DOMContentLoaded event was introduced. This new implementation generates client-side errors because it depends on the page lifecycle, and sometimes the event occurs but is not dispatched.
Solution: Add an event wrapper that checks the document state before adding the event listener or executing it

📝 Checklist

  • I have read the contribution guide.
  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@AylenHoz
Copy link
Contributor Author

I don't know why windows test failed if all tests passed

@thetutlage
Copy link
Member

Windows tests are failing because of an issue with @swc/core. I will pin its version to a old-version.

In this commit, the DOMContentLoaded event was introduced. This new implementation generates client-side errors because it depends on the page lifecycle, and sometimes the event occurs but is not dispatched.

Do you have any idea or examples in which case this event won't be fired?

@AylenHoz
Copy link
Contributor Author

Windows tests are failing because of an issue with @swc/core. I will pin its version to a old-version.

In this commit, the DOMContentLoaded event was introduced. This new implementation generates client-side errors because it depends on the page lifecycle, and sometimes the event occurs but is not dispatched.

Do you have any idea or examples in which case this event won't be fired?

In my team, we are rendering a page that checks certain values. If a check fails, we receive the error HTML from Youch and replace our page’s content with the HTML generated by Youch. In this scenario, the page had already been loaded, so the document was already in a ready state. By directly replacing the content with Youch’s generated HTML without navigating to another page, the ready state doesn’t change. As a result, Youch’s DOMContentLoaded listeners are never triggered

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.

DOMContentLoaded generates errors client-side
2 participants