From 72f3936365a03d9540893a3738186754a893804c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Fri, 11 Dec 2020 18:51:29 +0200 Subject: [PATCH] Fixes --- .../src/components/iframe/index.js | 30 ++++++++++++------- .../e2e-test-utils/src/show-block-toolbar.js | 6 +++- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/packages/block-editor/src/components/iframe/index.js b/packages/block-editor/src/components/iframe/index.js index aa170c4b26924c..707f4f2149c4de 100644 --- a/packages/block-editor/src/components/iframe/index.js +++ b/packages/block-editor/src/components/iframe/index.js @@ -148,27 +148,35 @@ function Iframe( { contentRef, children, head, ...props }, ref ) { const { contentDocument } = node; const { readyState } = contentDocument; - if ( readyState === 'interactive' || readyState === 'complete' ) { - setIframeDocument( contentDocument ); - setHead( contentDocument, head ); - setBodyClassName( contentDocument ); - styleSheetsCompat( contentDocument ); - bubbleEvents( contentDocument ); - setBodyClassName( contentDocument ); - contentRef.current = contentDocument.body; + if ( readyState !== 'interactive' && readyState !== 'complete' ) { + return false; } + + setIframeDocument( contentDocument ); + setHead( contentDocument, head ); + setBodyClassName( contentDocument ); + styleSheetsCompat( contentDocument ); + bubbleEvents( contentDocument ); + setBodyClassName( contentDocument ); + contentRef.current = contentDocument.body; + + return true; } - setDocumentIfReady(); + if ( setDocumentIfReady() ) { + return; + } // Document is not immediately loaded in Firefox. - node.addEventListener( 'load', setDocumentIfReady ); + node.addEventListener( 'load', () => { + setDocumentIfReady(); + } ); }, [] ); return (