Skip to content

Commit

Permalink
Fix jashkenas#1310 - off does not skip consecutive events.
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed May 14, 2012
1 parent 7d8c51a commit 83a24bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@
for (i = 0, length = list.length; i < length; i += 2) {
if (!(callback && list[i] !== callback || context && list[i + 1] !== context)) {
list.splice(i, 2);
i -= 2;
length -= 2;
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions test/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,12 @@ $(document).ready(function() {
ok(obj.off('event') === obj);
});

test("#1310 - off does not skip consecutive events", 0, function() {
var obj = _.extend({}, Backbone.Events);
obj.on('event', function() { ok(false); }, obj);
obj.on('event', function() { ok(false); }, obj);
obj.off(null, null, obj);
obj.trigger('event');
});

});

0 comments on commit 83a24bb

Please sign in to comment.