Make WordPress Core

Changeset 22737


Ignore:
Timestamp:
11/21/2012 08:09:28 AM (14 years ago)
Author:
koopersmith
Message:

Media: Prevent type and search attachments filters from short circuiting.

Moves the reference to the source collection out of the props model. If it was translated over to a query (which was potentially possible) which then fired an ajax request, jQuery would attempt to serialize an object recursively, which caused an infinite loop and much sadness for my browser.

see #21390.

File:
1 edited

Legend:

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

    r22706 r22737  
    326326
    327327                _changeFilteredProp: function( prop, model, term ) {
    328                         // Bail if we're currently searching for the same term.
    329                         if ( this.props.get( prop ) === term )
     328                        // If this is a query, updating the collection will be handled by
     329                        // `this._requery()`.
     330                        if ( this.props.get('query') )
    330331                                return;
    331332
     
    338339                        // from, then automatically generate a source from the existing
    339340                        // models.
    340                         if ( ! this.props.get('source') )
    341                                 this.props.set( 'source', new Attachments( this.models ) );
    342 
    343                         this.reset( this.props.get('source').filter( this.validator ) );
     341                        if ( ! this._source )
     342                                this._source = new Attachments( this.models );
     343
     344                        this.reset( this._source.filter( this.validator, this ) );
    344345                },
    345346
Note: See TracChangeset for help on using the changeset viewer.