Parse `attrs` before comparing to `attachment.attributes`. Small efficiency gain.
Props garyc40. Fixes #24753. git-svn-id: http://core.svn.wordpress.org/trunk@24800 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d07cc7be81
commit
ea1092eb7c
|
@ -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;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue