Skip to content

Commit

Permalink
Merge pull request #4264 from jgonggrijp/tryout-patch-3964
Browse files Browse the repository at this point in the history
Patch 3964 with linter fixes
  • Loading branch information
jgonggrijp authored Jul 18, 2023
2 parents 7af2818 + ffdaa71 commit 3b37e6a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@
removed.push(model);
this._removeReference(model, options);
}
if (models.length > 0 && !options.silent) delete options.index;
return removed;
},

Expand Down
14 changes: 14 additions & 0 deletions test/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2116,6 +2116,20 @@
assert.ok(collection.get(model));
});

QUnit.test('#3961 - add events sends options.index that correspond to wrong index', function(assert) {
var numModels = 4;
var models = _.each(['a', 'b', 'c', 'd'], function(val) {
return new Backbone.Model({id: val});
});
var collection = new Backbone.Collection(models);
models.shift(); // remove first element;
models.push(new Backbone.Model({id: 'e'}));
collection.on('add', function(model, coll, options){
assert.equal(options.index, undefined);
});
collection.set(models);
});

QUnit.test('#4233 - can instantiate new model in ES class Collection', function(assert) {
var model;
try {
Expand Down

0 comments on commit 3b37e6a

Please sign in to comment.