From c717bb47e21a06ee37ec689efe7e48655ea679ed Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Wed, 21 Nov 2012 08:09:28 +0000 Subject: [PATCH] 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. git-svn-id: http://core.svn.wordpress.org/trunk@22737 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/media-models.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wp-includes/js/media-models.js b/wp-includes/js/media-models.js index e6eedfb141..542cfc0aa8 100644 --- a/wp-includes/js/media-models.js +++ b/wp-includes/js/media-models.js @@ -325,8 +325,9 @@ window.wp = window.wp || {}; }, _changeFilteredProp: function( prop, model, term ) { - // Bail if we're currently searching for the same term. - if ( this.props.get( prop ) === term ) + // If this is a query, updating the collection will be handled by + // `this._requery()`. + if ( this.props.get('query') ) return; if ( term && ! this.filters[ prop ] ) @@ -337,10 +338,10 @@ window.wp = window.wp || {}; // If no `Attachments` model is provided to source the searches // from, then automatically generate a source from the existing // models. - if ( ! this.props.get('source') ) - this.props.set( 'source', new Attachments( this.models ) ); + if ( ! this._source ) + this._source = new Attachments( this.models ); - this.reset( this.props.get('source').filter( this.validator ) ); + this.reset( this._source.filter( this.validator, this ) ); }, _changeSearch: function( model, term ) {