mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
off is chainable when there are no events.
This commit is contained in:
@@ -116,7 +116,7 @@
|
||||
var event, calls, node, tail, cb, ctx;
|
||||
|
||||
// No events, or removing *all* events.
|
||||
if (!(calls = this._callbacks)) return;
|
||||
if (!(calls = this._callbacks)) return this;
|
||||
if (!(events || callback || context)) {
|
||||
delete this._callbacks;
|
||||
return this;
|
||||
|
||||
@@ -167,4 +167,16 @@ $(document).ready(function() {
|
||||
obj.trigger('x y');
|
||||
});
|
||||
|
||||
test("off is chainable", function() {
|
||||
var obj = _.extend({}, Backbone.Events);
|
||||
// With no events
|
||||
ok(obj.off() === obj);
|
||||
// When removing all events
|
||||
obj.on('event', function(){}, obj);
|
||||
ok(obj.off() === obj);
|
||||
// When removing some events
|
||||
obj.on('event', function(){}, obj);
|
||||
ok(obj.off('event') === obj);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user