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:
Andrew Ozz 2015-03-07 16:53:27 +00:00
parent 9c20c8f7b7
commit f02a17e2a1
3 changed files with 14 additions and 13 deletions

View File

@ -467,7 +467,7 @@ window.wp = window.wp || {};
var dom = editor.dom, var dom = editor.dom,
styles = '', styles = '',
bodyClasses = editor.getBody().className || '', bodyClasses = editor.getBody().className || '',
iframe, iframeDoc, observer, i, resize; iframe, iframeDoc, observer, i;
content.innerHTML = ''; content.innerHTML = '';
head = head || ''; head = head || '';
@ -543,7 +543,7 @@ window.wp = window.wp || {};
iframeDoc.close(); iframeDoc.close();
resize = function() { function resize() {
var $iframe, iframeDocHeight; var $iframe, iframeDocHeight;
// Make sure the iframe still exists. // Make sure the iframe still exists.
@ -556,18 +556,20 @@ window.wp = window.wp || {};
editor.nodeChanged(); editor.nodeChanged();
} }
} }
}; }
if ( MutationObserver ) { if ( MutationObserver ) {
observer = new MutationObserver( _.debounce( function() { observer = new MutationObserver( _.debounce( resize, 100 ) );
resize();
}, 100 ) );
observer.observe( iframeDoc.body, { observer.observe( iframeDoc.body, {
attributes: true, attributes: true,
childList: true, childList: true,
subtree: true subtree: true
} ); } );
$( node ).one( 'wp-mce-view-unbind', function() {
observer.disconnect();
} );
} else { } else {
for ( i = 1; i < 6; i++ ) { for ( i = 1; i < 6; i++ ) {
setTimeout( resize, i * 700 ); setTimeout( resize, i * 700 );
@ -580,12 +582,11 @@ window.wp = window.wp || {};
if ( importStyles ) { if ( importStyles ) {
editor.on( 'wp-body-class-change', classChange ); editor.on( 'wp-body-class-change', classChange );
}
$( node ).one( 'wp-mce-view-unbind', function() { $( node ).one( 'wp-mce-view-unbind', function() {
observer.disconnect(); editor.off( 'wp-body-class-change', classChange );
editor.off( 'wp-body-class-change', classChange ); } );
} ); }
}, 50 ); }, 50 );
callback && callback.apply( this, arguments ); callback && callback.apply( this, arguments );

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.