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(playground): dispatch readystatechange + bubble DOMContentLoaded on document #10946

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

caugner
Copy link
Contributor

@caugner caugner commented Apr 17, 2024

Summary

Fixes #10766.
Fixes #10771.

Problem

The Playground doesn't dispatch a readystatechange event, and only dispatches the DOMContentLoaded on the window, not on the document, so event listeners on the document aren't called.

Solution

  1. Also dispatch a readystatechange event (once between DOMContentLoaded and load, because document.readyState will already be completed.)
  2. Dispatch the DOMContentLoaded on document and let it bubble.

(Kudos to @Kaiido for the proposing this solution.)


Screenshots

Before

image

After

image

How did you test this change?

Deployed to stage and verified that it works as expected on https://developer.allizom.org/en-US/docs/web/api/document/readystatechange_event#result.

@caugner caugner marked this pull request as ready for review April 18, 2024 15:16
@caugner caugner requested a review from a team as a code owner April 18, 2024 15:16
Copy link
Contributor

@fiji-flo fiji-flo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for fixing

@caugner caugner changed the title fix(playground): dispatch bubbling DOMContentLoaded/readystatechange/load events on document fix(playground): dispatch bubbling DOMContentLoaded + readystatechange events on document Apr 18, 2024
@caugner caugner changed the title fix(playground): dispatch bubbling DOMContentLoaded + readystatechange events on document fix(playground): dispatch readystatechange + bubble DOMContentLoaded on document Apr 18, 2024
@caugner caugner merged commit 7229dd3 into main Apr 18, 2024
13 checks passed
@caugner caugner deleted the fix-playground-event-dispatching branch April 18, 2024 15:43
mostafaroshdy1 pushed a commit to mostafaroshdy1/yari that referenced this pull request Apr 19, 2024
…on document (mdn#10946)

fix(playground): dispatch readystatechange event
fix(playground): dispatch DOMContentLoaded event on document + bubble
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.

Window load example regression DOMContentLoaded does not fire in LiveSample
2 participants