Parse attrs before comparing to attachment.attributes. Small efficiency gain.

Props garyc40. Fixes #24753.

git-svn-id: https://develop.svn.wordpress.org/trunk@24800 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2013-07-27 07:09:05 +00:00
parent 1fd6c87716
commit 9d2e982a79

View File

@ -401,7 +401,6 @@ window.wp = window.wp || {};
attachments.on( 'add change remove', this._validateHandler, this ); attachments.on( 'add change remove', this._validateHandler, this );
attachments.on( 'reset', this._validateAllHandler, this ); attachments.on( 'reset', this._validateAllHandler, this );
this.validateAll( attachments ); this.validateAll( attachments );
return this; return this;
}, },
@ -487,7 +486,8 @@ window.wp = window.wp || {};
resp = [resp]; resp = [resp];
return _.map( resp, function( attrs ) { return _.map( resp, function( attrs ) {
var id, attachment; var id, attachment, newAttributes;
if ( attrs instanceof Backbone.Model ) { if ( attrs instanceof Backbone.Model ) {
id = attrs.get( 'id' ); id = attrs.get( 'id' );
attrs = attrs.attributes; attrs = attrs.attributes;
@ -495,9 +495,11 @@ window.wp = window.wp || {};
id = attrs.id; id = attrs.id;
} }
attachment = Attachment.get( attrs.id ); attachment = Attachment.get( id );
if ( ! _.isEqual( attachment.attributes, attrs ) ) newAttributes = attachment.parse( attrs, xhr );
attachment.set( attachment.parse( attrs, xhr ) );
if ( ! _.isEqual( attachment.attributes, newAttributes ) )
attachment.set( newAttributes );
return attachment; return attachment;
}); });