From eb9f54c8fe9efa878093fa24a32755ad7d6fd43d Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Thu, 14 Oct 2010 07:36:11 -0400 Subject: [PATCH] willbailey's patch to use getByCid for internal lookups ... much safer. --- backbone.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backbone.js b/backbone.js index 3a029d08..bc08d58b 100644 --- a/backbone.js +++ b/backbone.js @@ -422,7 +422,7 @@ // hash indexes for `id` and `cid` lookups. _add : function(model, options) { options || (options = {}); - var already = this.get(model); + var already = this.getByCid(model); if (already) throw new Error(["Can't add the same model to a set twice", already.id]); this._byId[model.id] = model; this._byCid[model.cid] = model; @@ -439,7 +439,7 @@ // hash indexes for `id` and `cid` lookups. _remove : function(model, options) { options || (options = {}); - model = this.get(model); + model = this.getByCid(model); if (!model) return null; delete this._byId[model.id]; delete this._byCid[model.cid];