mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Fix #2296 get works with 0 as a model id
This commit is contained in:
@@ -726,7 +726,7 @@
|
||||
// Get a model from the set by id.
|
||||
get: function(obj) {
|
||||
if (obj == null) return void 0;
|
||||
return this._byId[obj.id || obj.cid || obj];
|
||||
return this._byId[obj.id != null ? obj.id : obj.cid || obj];
|
||||
},
|
||||
|
||||
// Get the model at the given index.
|
||||
|
||||
@@ -62,8 +62,10 @@ $(document).ready(function() {
|
||||
strictEqual(collection.last().get('a'), 4);
|
||||
});
|
||||
|
||||
test("get", 5, function() {
|
||||
test("get", 6, function() {
|
||||
equal(col.get(0), d);
|
||||
var d2 = d.clone();
|
||||
equal(col.get(d2), d);
|
||||
equal(col.get(2), b);
|
||||
equal(col.get({id: 1}), c);
|
||||
equal(col.get(c.clone()), c);
|
||||
|
||||
Reference in New Issue
Block a user