-
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 Custom HTML error when block is empty #8556
Conversation
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 @Rahmon!
@@ -145,7 +145,7 @@ class Sandbox extends Component { | |||
if ( 'DIV' === potentialIframe.tagName || 'SPAN' === potentialIframe.tagName ) { | |||
potentialIframe = potentialIframe.children[0]; | |||
} | |||
if ( 'IFRAME' === potentialIframe.tagName ) { | |||
if ( potentialIframe && 'IFRAME' === potentialIframe.tagName ) { |
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.
So was the error caused by property access on the undefined value?
If so, shouldn't we also need to consider the .tagName
property access in the condition immediately preceding this one?
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.
potentialIframe && potentialIframe.tagname && 'IFRAME' === potentialIframe.tagName
is that way, right?
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.
If so, shouldn't we also need to consider the .tagName property access in the condition immediately preceding this one?
potentialIframe
isn't undefined until it's re-assigned in the condition above.
What is this code even doing? Can we just remove it? |
cc. @notnownikki |
@aduth |
Admittedly, the code to discover the first iframe is janky. Sorry about that. |
Description
Fix Custom HTML block error when block is empty and Preview button is clicked.
Closes: #7277
How has this been tested?
This has been tested with "npm test" and manually on Chrome and Firefox
Types of changes
Bug fix
Checklist: