[Pkg-javascript-commits] [backbone] 01/21: multiple models with the same ID should be allowed in a collection.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:01:04 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.5.2
in repository backbone.

commit 6d07d2f0e2a1e93c4c79bf50e0ca5e627f0ffd87
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Tue Jul 5 16:40:23 2011 -0400

    multiple models with the same ID should be allowed in a collection.
---
 backbone.js        | 2 +-
 test/collection.js | 9 +--------
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/backbone.js b/backbone.js
index 18d4843..5455ebc 100644
--- a/backbone.js
+++ b/backbone.js
@@ -582,7 +582,7 @@
       options || (options = {});
       model = this._prepareModel(model, options);
       if (!model) return false;
-      var already = this.getByCid(model) || 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;
diff --git a/test/collection.js b/test/collection.js
index 58daca2..df44914 100644
--- a/test/collection.js
+++ b/test/collection.js
@@ -97,16 +97,9 @@ $(document).ready(function() {
 
   test("Collection: add model to collection twice", function() {
     try {
-      // same id, different cid
-      col.add({id: a.id, label: a.label});
-      ok(false, "duplicate; expected add to fail");
-    } catch (e) {
-      equals(e.message, "Can't add the same model to a set twice,3");
-    }
-    try {
       // no id, same cid
       var a2 = new Backbone.Model({label: a.label});
-      a2.cid = a.cid
+      a2.cid = a.cid;
       col.add(a2);
       ok(false, "duplicate; expected add to fail");
     } catch (e) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list