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 DOMContentLoaded event manually #10770

Merged
merged 1 commit into from Mar 22, 2024

Conversation

caugner
Copy link
Contributor

@caugner caugner commented Mar 22, 2024

Summary

Fixes #9324.
Fixes #9409.
Fixes #10310.
Fixes #10766.
Fixes #10771.
Fixes #10772.

Problem

The DOMContentLoaded wasn't fired in the Playground, because the HTML is inserted only after the original DOMContentLoaded event is fired.

Solution

Manually fire a DOMContenLoaded event, just like we manually fire a load event.


Screenshots

Before

Prod: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tab_role#example

image

After

Stage: https://developer.allizom.org/en-US/docs/Web/Accessibility/ARIA/Roles/tab_role#example

image

How did you test this change?

Deployed this to change and tested the live sample at https://developer.allizom.org/en-US/docs/Web/Accessibility/ARIA/Roles/tab_role#example, mentioned in #9324.

@caugner caugner requested a review from a team as a code owner March 22, 2024 14:44
@caugner caugner merged commit 2515b3d into main Mar 22, 2024
12 checks passed
@caugner caugner deleted the dispatch-DOMContentLoaded-manually branch March 22, 2024 14:48
@@ -121,6 +121,7 @@
script.textContent = state.js;
document.body.appendChild(script);

dispatchEvent(new Event("DOMContentLoaded"));
Copy link

Choose a reason for hiding this comment

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

This should be fired on the document, not the window (technically even the load one below has a legacy retarget to doc). Don't forget to make it bubble then.

Copy link

@Kaiido Kaiido left a comment

Choose a reason for hiding this comment

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

This change would not fix the snippets listening for the event from the document.

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