mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-23 05:48:10 -05:00
Merge pull request #1008 from braddunbar/missing-callback
`on` is a noop if no callback is provided
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user