diff --git a/backbone.js b/backbone.js index deedb0ed..5476b6a1 100644 --- a/backbone.js +++ b/backbone.js @@ -511,8 +511,10 @@ if (!(model = models[i] = this._prepareModel(models[i], options))) { throw new Error("Can't add an invalid model to a collection"); } - if (cids[cid = model.cid] || this._byCid[cid] || - (((id = model.id) != null) && (ids[id] || this._byId[id]))) { + + cid = model.cid; + id = model.id; + if (cids[cid] || this._byCid[cid] || (id != null && (ids[id] || this._byId[id]))) { throw new Error("Can't add the same model to a collection twice"); } cids[cid] = ids[id] = model;