From 3761d281883ed52b309557a1de5a98b49d81ae9b Mon Sep 17 00:00:00 2001 From: vlad Date: Wed, 8 Feb 2012 16:40:31 -0800 Subject: [PATCH] fixes #972 by cleaning up a messy conditional --- backbone.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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;