Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

`HasMany.addRelated` should also disable `parse`.

Fixes the last failing test on Backbone 1.0.0.
  • Loading branch information...
commit 1156f99413bdf037cebd8a376388ac581b74866e 1 parent 86ccf0d
@PaulUithol authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 backbone-relational.js
View
8 backbone-relational.js
@@ -886,7 +886,9 @@
}
else {
// If `merge` is true, update models here, instead of during update.
- model = this.relatedModel.findOrCreate( attributes, _.extend( { merge: true }, options, { create: this.options.createModels } ) );
+ model = this.relatedModel.findOrCreate( attributes,
+ _.extend( { merge: true }, options, { create: this.options.createModels } )
+ );
}
model && toAdd.push( model );
@@ -899,6 +901,8 @@
related = this._prepareCollection();
}
+ // By now, both `merge` and `parse` will already have been executed for models if they were specified.
+ // Disable them to prevent additional calls.
related.set( toAdd, _.defaults( { merge: false, parse: false }, options ) );
}
@@ -1012,7 +1016,7 @@
var dit = this;
model.queue( function() {
if ( dit.related && !dit.related.get( model ) ) {
- dit.related.add( model, options );
+ dit.related.add( model, _.defaults( { merge: false, parse: false }, options ) );
}
});
},

0 comments on commit 1156f99

Please sign in to comment.
Something went wrong with that request. Please try again.