Skip to content

Commit

Permalink
Iframe: remove obsolete readyState checks (#51003)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix authored May 26, 2023
1 parent 22435b6 commit 1a2d5f6
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,11 @@ function Iframe( {
function preventFileDropDefault( event ) {
event.preventDefault();
}
function setDocumentIfReady() {
function onLoad() {
const { contentDocument, ownerDocument } = node;
const { readyState, documentElement } = contentDocument;
const { documentElement } = contentDocument;
iFrameDocument = contentDocument;

if ( readyState !== 'interactive' && readyState !== 'complete' ) {
return false;
}

bubbleEvents( contentDocument );
setIframeDocument( contentDocument );
clearerRef( documentElement );
Expand Down Expand Up @@ -178,14 +174,12 @@ function Iframe( {
preventFileDropDefault,
false
);
return true;
}

// Document set with srcDoc is not immediately ready.
node.addEventListener( 'load', setDocumentIfReady );
node.addEventListener( 'load', onLoad );

return () => {
node.removeEventListener( 'load', setDocumentIfReady );
node.removeEventListener( 'load', onLoad );
iFrameDocument?.removeEventListener(
'dragover',
preventFileDropDefault
Expand Down

1 comment on commit 1a2d5f6

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 1a2d5f6.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5091457685
📝 Reported issues:

Please sign in to comment.