From 10e93c557bb4e5d16b325aa4bea68bb990c66982 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 26 Jul 2016 22:05:39 +0000 Subject: [PATCH] TinyMCE, wpView: bail early when the iframe node is not attached to the DOM. We can't load any HTML in it as here is no `iframe.contentWindow` in these cases. See #36434. git-svn-id: https://develop.svn.wordpress.org/trunk@38157 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/mce-view.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wp-includes/js/mce-view.js b/src/wp-includes/js/mce-view.js index d2c29f7e88..10e33cc3b0 100644 --- a/src/wp-includes/js/mce-view.js +++ b/src/wp-includes/js/mce-view.js @@ -539,6 +539,14 @@ dom.add( node, 'span', { 'class': 'wpview-end' } ); } ); + // Bail if the iframe node is not attached to the DOM. + // Happens when the view is dragged in the editor. + // There is a browser restriction when iframes are moved in the DOM. They get emptied. + // The iframe will be rerendered after dropping the view node at the new location. + if ( ! iframe.contentWindow ) { + return; + } + iframeDoc = iframe.contentWindow.document; iframeDoc.open();