mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Fix _removeModels regression
Fixes #3693. This leaves open the question of whether events triggered on the model during a ‘remove’ listener should also trigger on the model. Just something to revisit for V2. ```js col.on('other', (model) => { // Should this be triggered? }); col.on('remove', (model) => { // If the model is really "removed" (we can't `#get` it anymore) // by the time this listener is called, then I'd argue that this // shouldn't trigger the 'other' event on the collection... model.trigger('other'); }); ```
This commit is contained in:
@@ -298,12 +298,13 @@
|
||||
deepEqual(col.pluck('id'), [1, 2, 3]);
|
||||
});
|
||||
|
||||
test("remove", 10, function() {
|
||||
test("remove", 11, function() {
|
||||
var removed = null;
|
||||
var result = null;
|
||||
col.on('remove', function(model, col, options) {
|
||||
removed = model.get('label');
|
||||
equal(options.index, 3);
|
||||
equal(col.get(model), undefined, '#3693: model cannot be fetched from collection');
|
||||
});
|
||||
result = col.remove(d);
|
||||
equal(removed, 'd');
|
||||
|
||||
Reference in New Issue
Block a user