Permalink
Browse files

#4103 check if obj is Model in Collection.get (#4104)

  • Loading branch information...
1 parent df3366d commit 7da4ed73e7402baf614a50a6551d47ace68b5239 @ksladkov ksladkov committed with akre54 Dec 1, 2016
Showing with 6 additions and 1 deletion.
  1. +1 −1 backbone.js
  2. +5 −0 test/collection.js
View
@@ -998,7 +998,7 @@
get: function(obj) {
if (obj == null) return void 0;
return this._byId[obj] ||
- this._byId[this.modelId(obj.attributes || obj)] ||
+ this._byId[this.modelId(this._isModel(obj) ? obj.attributes : obj)] ||
obj.cid && this._byId[obj.cid];
},
View
@@ -2074,4 +2074,9 @@
assert.equal(fired, false);
});
+ QUnit.test('get models with `attributes` key', function(assert) {
+ var model = {id: 1, attributes: {}};
+ var collection = new Backbone.Collection([model]);
+ assert.ok(collection.get(model));
+ });
})(QUnit);

0 comments on commit 7da4ed7

Please sign in to comment.