Permalink
Browse files

When resetting the subset, repopulate with filtered models from the p…

…arent.

All models in the subset should be the same instance as in the parent
collection. Corrected test to reflect this.
  • Loading branch information...
1 parent 77f88d7 commit ed282a9882f1b84e5f3b697c8b227f96e60a0f43 @saimonmoore saimonmoore committed Nov 30, 2011
Showing with 5 additions and 3 deletions.
  1. +4 −2 backbone.subset.js
  2. +1 −1 test/test.js
View
@@ -74,8 +74,10 @@
this.each(this._unbindModelEvents);
this._reset();
- _.each(models, function (model) {
- this._addToSubset(model, {silent: true});
+ this.parent().each(function (model) {
+ if (this.sieve(model)) {
+ this._addToSubset(model, {silent: true});
+ }
}, this);
if (!options.silent) {
View
@@ -190,6 +190,6 @@ describe('Aggregated collections', function () {
assert.deepEqual(tasks.pluck('id'), [0, 4, 5]);
assert.deepEqual(archived_tasks.pluck('id'), [5]);
assert.deepEqual(_.pluck(tasks.models, 'cid'), ['c6', 'c8', 'c9']);
- assert.deepEqual(_.pluck(archived_tasks.models, 'cid'), ['c11']);
+ assert.deepEqual(_.pluck(archived_tasks.models, 'cid'), ['c9']);
});
});

0 comments on commit ed282a9

Please sign in to comment.