mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Use matches in .where
This commit is contained in:
committed by
Adam Krebs
parent
5025d3ce71
commit
b93030b0d8
@@ -833,12 +833,9 @@
|
||||
// Return models with matching attributes. Useful for simple cases of
|
||||
// `filter`.
|
||||
where: function(attrs, first) {
|
||||
if (_.isEmpty(attrs)) return first ? void 0 : [];
|
||||
var matches = _.matches(attrs);
|
||||
return this[first ? 'find' : 'filter'](function(model) {
|
||||
for (var key in attrs) {
|
||||
if (attrs[key] !== model.get(key)) return false;
|
||||
}
|
||||
return true;
|
||||
return matches(model.attributes);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user