-
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
Fix crash when switching to code editor #61173
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -55 B (0%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
@draganescu Didn't you fix this? |
node._load = () => { | ||
setIframeDocument( node.contentDocument ); | ||
}; |
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.
@ellatrix I'm curious why this extra _load()
function was added? It seems like it should be doing the same thing as onLoad()
below.
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.
This is not the same as document load which only happens after the initial DOM is loaded and assets are loaded. The load function is called before the browser moves on to parse any other styles and script and the body tag below. It's needed because we're rendering our own body element, which (if I remember correctly) must be available to any scripts loaded (instead of the one we're removing). See #52405.
This was closed by #61200 |
What?
Fixes an issue where triggering zoom-out while the code editor was open caused an editor crash.
Why?
Bug fix.
How?
On page load, there is a script to remove the
body
of the document so it can be replaced with the React one in the portal. However, in the effect, we're referencing thebody
that gets removed, so on unmount (when switching to the code editor) you get the error:Uncaught TypeError: iframeDocument.body is null
.This is fixed by moving
body
-related code inside the portal.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast