fixes #972 by cleaning up a messy conditional

This commit is contained in:
vlad
2012-02-08 16:40:31 -08:00
parent b1e2e69977
commit 3761d28188

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;