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

JSBreakpointModule: add document.readyState checks #5495

Open
wants to merge 1 commit into
base: rel-1.5
Choose a base branch
from

Conversation

stsrki
Copy link
Collaborator

@stsrki stsrki commented May 5, 2024

Closes #5482

@stsrki stsrki requested a review from David-Moreira May 5, 2024 13:11
Copy link
Contributor

@David-Moreira David-Moreira left a comment

Choose a reason for hiding this comment

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

Looks ok, see comment for making sure the event is effectively attached? Also were you able to reproduce the issue? Or just trying to make the code more resilient?

}
else {
//The browser does not support Javascript event binding
if (document.readyState === 'interactive' || document.readyState === 'complete') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember using the event DOMContentLoaded for doing stuff when the Dom is available. Is that no better? Since it seems like you are not guaranting that this code attaches the events in case the js is loaded and the document is not on those states? Am I wrong?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The JS module deferred loaded, so we cannot listen for DOMContentLoaded.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I don't follow. Do you mean, that tipically it will execute after the DOMContentLoaded has already been called?

How do you guarantee if the following condition is not true (document.readyState === 'interactive' || document.readyState === 'complete') that the events will be registered?

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.

None yet

2 participants