TinyMCE wpView: improve unbinding of mutationObserver in nested iframes. Props iseulde. See #31412.
Built from https://develop.svn.wordpress.org/trunk@31667 git-svn-id: http://core.svn.wordpress.org/trunk@31648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9c20c8f7b7
commit
f02a17e2a1
|
@ -467,7 +467,7 @@ window.wp = window.wp || {};
|
|||
var dom = editor.dom,
|
||||
styles = '',
|
||||
bodyClasses = editor.getBody().className || '',
|
||||
iframe, iframeDoc, observer, i, resize;
|
||||
iframe, iframeDoc, observer, i;
|
||||
|
||||
content.innerHTML = '';
|
||||
head = head || '';
|
||||
|
@ -543,7 +543,7 @@ window.wp = window.wp || {};
|
|||
|
||||
iframeDoc.close();
|
||||
|
||||
resize = function() {
|
||||
function resize() {
|
||||
var $iframe, iframeDocHeight;
|
||||
|
||||
// Make sure the iframe still exists.
|
||||
|
@ -556,18 +556,20 @@ window.wp = window.wp || {};
|
|||
editor.nodeChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if ( MutationObserver ) {
|
||||
observer = new MutationObserver( _.debounce( function() {
|
||||
resize();
|
||||
}, 100 ) );
|
||||
observer = new MutationObserver( _.debounce( resize, 100 ) );
|
||||
|
||||
observer.observe( iframeDoc.body, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
subtree: true
|
||||
} );
|
||||
|
||||
$( node ).one( 'wp-mce-view-unbind', function() {
|
||||
observer.disconnect();
|
||||
} );
|
||||
} else {
|
||||
for ( i = 1; i < 6; i++ ) {
|
||||
setTimeout( resize, i * 700 );
|
||||
|
@ -580,12 +582,11 @@ window.wp = window.wp || {};
|
|||
|
||||
if ( importStyles ) {
|
||||
editor.on( 'wp-body-class-change', classChange );
|
||||
}
|
||||
|
||||
$( node ).one( 'wp-mce-view-unbind', function() {
|
||||
observer.disconnect();
|
||||
editor.off( 'wp-body-class-change', classChange );
|
||||
} );
|
||||
$( node ).one( 'wp-mce-view-unbind', function() {
|
||||
editor.off( 'wp-body-class-change', classChange );
|
||||
} );
|
||||
}
|
||||
}, 50 );
|
||||
|
||||
callback && callback.apply( this, arguments );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31666';
|
||||
$wp_version = '4.2-alpha-31667';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue