Merge pull request #1746 from michalkot/master.

Allow empty routes.
This commit is contained in:
Brad Dunbar
2012-10-17 07:53:15 -04:00
parent d73b6d7da9
commit db26c74d1a
2 changed files with 12 additions and 1 deletions

View File

@@ -947,7 +947,7 @@
_bindRoutes: function() {
if (!this.routes) return;
var route, routes = _.keys(this.routes);
while (typeof (route = routes.pop()) !== 'undefined') {
while ((route = routes.pop()) != null) {
var name = this.routes[route];
this.route(route, name, this[name]);
}

View File

@@ -481,4 +481,15 @@ $(document).ready(function() {
});
});
test("#1746 - Router allows empty route.", 1, function() {
var Router = Backbone.Router.extend({
routes: {'': 'empty'},
empty: function(){},
route: function(route){
strictEqual(route, '');
}
});
new Router;
});
});