Make WordPress Core

Changeset 22454


Ignore:
Timestamp:
11/07/2012 10:43:16 PM (12 years ago)
Author:
koopersmith
Message:

Media: Improve memory management of views, events, and DOM nodes. see #21390.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/media-views.js

    r22437 r22454  
    102102
    103103            if ( previous ) {
     104                // Replace the view in place.
     105                previous.$el.replaceWith( view.$el );
     106
    104107                // Fire the view's `destroy` event if it exists.
    105108                if ( previous.destroy )
     
    107110                // Undelegate events.
    108111                previous.undelegateEvents();
    109 
    110                 // Replace the view in place.
    111                 previous.$el.replaceWith( view.$el );
    112112            }
    113113
     
    10681068        destroy: function() {
    10691069            wp.Uploader.queue.off( 'add remove reset change:percent', this.renderUploadProgress, this );
     1070            this.remove();
    10701071        },
    10711072
     
    11251126
    11261127        destroy: function() {
     1128            this.remove();
    11271129            _.each( this._views, function( view ) {
    11281130                if ( view.destroy )
     
    14051407
    14061408        destroy: function() {
     1409            this.remove();
    14071410            _.each( this._views, function( view ) {
    14081411                if ( view.destroy )
     
    15631566            this.model.off( null, null, this );
    15641567            this.$el.off( 'click', 'a', this.preventDefault );
     1568            this.remove();
    15651569        },
    15661570
     
    17541758            this.model.off( 'change:edge change:gutter', this.css, this );
    17551759            $(window).off( 'resize.attachments', this._resizeCss );
     1760            this.remove();
    17561761        },
    17571762
     
    19631968                AttachmentView: this.options.AttachmentView
    19641969            });
     1970        },
     1971
     1972        destroy: function() {
     1973            this.remove();
     1974            this.toolbar.destroy();
     1975            this.attachments.destroy();
    19651976        },
    19661977
     
    20592070
    20602071        destroy: function() {
     2072            this.remove();
    20612073            this.collection.off( 'add remove reset', this.refresh, this );
     2074            this.attachments.destroy();
    20622075        },
    20632076
Note: See TracChangeset for help on using the changeset viewer.