Browse files

Idempotent add: don't refuse models with undefined id

This fixes an issue where BackBone models without id were being
prevented from collection insertion.
  • Loading branch information...
1 parent ea8de61 commit e22c309b6932dd9195966585a0cbf2c42a1277ae @jasonm jasonm committed Sep 9, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 vendor/assets/javascripts/extensions/backbone.collection.idempotent.js
View
2 vendor/assets/javascripts/extensions/backbone.collection.idempotent.js
@@ -2,7 +2,7 @@ Backbone.Collection.prototype._addWithIdCheck = function(model, options) {
var idAttribute = model.idAttribute || this.model.prototype.idAttribute;
var modelId = model[idAttribute];
- if (this.get(modelId) === undefined) {
+ if (modelId === undefined || this.get(modelId) === undefined) {
this._addWithoutIdCheck(model, options);
}
};

0 comments on commit e22c309

Please sign in to comment.