Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

`on` is a noop if no callback is provided

  • Loading branch information...
commit 8b285c6c830d84b39f355c72db3e931fdb785130 1 parent b9e36f0
@braddunbar braddunbar authored
Showing with 5 additions and 0 deletions.
  1. +1 −0  backbone.js
  2. +4 −0 test/events.js
View
1  backbone.js
@@ -86,6 +86,7 @@
// function. Passing `"all"` will bind the callback to all events fired.
on: function(events, callback, context) {
var ev;
+ if (!callback) return this;
events = events.split(/\s+/);
var calls = this._callbacks || (this._callbacks = {});
while (ev = events.shift()) {
View
4 test/events.js
@@ -145,4 +145,8 @@ $(document).ready(function() {
equal(counter, 2, 'unbind does not alter callback list');
});
+ test("if no callback is provided, `on` is a noop", function() {
+ _.extend({}, Backbone.Events).bind('test').trigger('test');
+ });
+
});
Please sign in to comment.
Something went wrong with that request. Please try again.