willbailey's patch to use getByCid for internal lookups ... much safer.

This commit is contained in:
Jeremy Ashkenas
2010-10-14 07:36:11 -04:00
parent 184687b28f
commit eb9f54c8fe

View File

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