Make WordPress Core

Ticket #31412: 31412.22.patch

File 31412.22.patch, 1.7 KB (added by iseulde, 10 years ago)
  • src/wp-includes/js/mce-view.js

     
    467467                                var dom = editor.dom,
    468468                                        styles = '',
    469469                                        bodyClasses = editor.getBody().className || '',
    470                                         iframe, iframeDoc, observer, i, resize;
     470                                        iframe, iframeDoc, observer, i;
    471471
    472472                                content.innerHTML = '';
    473473                                head = head || '';
     
    543543
    544544                                        iframeDoc.close();
    545545
    546                                         resize = function() {
     546                                        function resize() {
    547547                                                var $iframe, iframeDocHeight;
    548548
    549549                                                // Make sure the iframe still exists.
     
    556556                                                                editor.nodeChanged();
    557557                                                        }
    558558                                                }
    559                                         };
     559                                        }
    560560
    561561                                        if ( MutationObserver ) {
    562                                                 observer = new MutationObserver( _.debounce( function() {
    563                                                         resize();
    564                                                 }, 100 ) );
     562                                                observer = new MutationObserver( _.debounce( resize, 100 ) );
    565563
    566564                                                observer.observe( iframeDoc.body, {
    567565                                                        attributes: true,
    568566                                                        childList: true,
    569567                                                        subtree: true
    570568                                                } );
     569
     570                                                $( node ).one( 'wp-mce-view-unbind', function() {
     571                                                        observer.disconnect();
     572                                                } );
    571573                                        } else {
    572574                                                for ( i = 1; i < 6; i++ ) {
    573575                                                        setTimeout( resize, i * 700 );
     
    580582
    581583                                        if ( importStyles ) {
    582584                                                editor.on( 'wp-body-class-change', classChange );
    583                                         }
    584585
    585                                         $( node ).one( 'wp-mce-view-unbind', function() {
    586                                                 observer.disconnect();
    587                                                 editor.off( 'wp-body-class-change', classChange );
    588                                         } );
     586                                                $( node ).one( 'wp-mce-view-unbind', function() {
     587                                                        editor.off( 'wp-body-class-change', classChange );
     588                                                } );
     589                                        }
    589590                                }, 50 );
    590591
    591592                                callback && callback.apply( this, arguments );