-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Block Editor: Simulated Media Query: Skip CSS rule if not style rule #20226
Conversation
packages/block-editor/src/components/simulate-media-query/index.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! Looks good apart from my comment below. Would you like to fix the window
check here, or shall I in a separate PR? I should be doing a PR anyway to address the other issues you mentioned.
packages/block-editor/src/components/simulate-media-query/index.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/simulate-media-query/index.js
Outdated
Show resolved
Hide resolved
I'm still unclear whether we might expect |
rule.type !== window.CSSRule.STYLE_RULE && | ||
rule.type !== window.CSSRule.MEDIA_RULE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is slightly sketchy to not be guarding window
here, but if we assume that getStyleSheetsThatMatchHostname
is returning an empty array for any non-DOM environments, then this logic (within styleSheets.forEach
) would never be reached.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still unclear whether we might expect window to be undeclared in the environments we're trying to anticipate (I'm assuming that this code is being run in Native as well?).
I'm not sure about this, or even how to test it - would I need a dev version of the app?
Approving in any case as this fixes the IE issue.
In speaking with @hypest about this, it appears that React Native does define a But I suspect it's still a good idea to have some guardedness, related to the same ideas proposed in #16227, for modules intended to be used server-side (by third-parties). It's more a problem for code which executes as a side-effect of being imported, so maybe not strictly necessary here. Perhaps we may decide to remove it in the future, but in the meantime the updated condition is at least more accurate to what we hope to achieve with it (resolving thrown error if |
Related: #19082
This pull request seeks to resolve an error preventing the editor from loading in Internet Explorer.
See TBD for more context:
Testing Instructions:
Repeat testing instructions from #19082.
Verify that the editor loads in Internet Explorer.