Merge pull request #980 from vovik/new-master

fixes #972 by cleaning up a messy conditional
This commit is contained in:
brad dunbar
2012-02-09 05:57:02 -08:00

View File

@@ -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;