diff --git a/backbone.js b/backbone.js index 900933c7a..b6e9732c9 100644 --- a/backbone.js +++ b/backbone.js @@ -986,7 +986,11 @@ // route: function(route, name, callback) { if (!_.isRegExp(route)) route = this._routeToRegExp(route); - if (!callback) callback = _.isFunction(name) ? name : this[name]; + if (_.isFunction(name)) { + callback = name; + name = ''; + } + if (!callback) callback = this[name]; var router = this; Backbone.history.route(route, function(fragment) { var args = router._extractParameters(route, fragment); diff --git a/test/router.js b/test/router.js index e0c86c2cf..e6e1b3d6e 100644 --- a/test/router.js +++ b/test/router.js @@ -286,7 +286,10 @@ $(document).ready(function() { equal(router.anything, 'doesnt-match-a-route'); }); - test("routes (function)", 2, function() { + test("routes (function)", 3, function() { + router.on('route', function(name) { + ok(name === ''); + }); equal(ExternalObject.value, 'unset'); location.replace('http://example.com#function/set'); Backbone.history.checkUrl();