diff --git a/backbone.js b/backbone.js index 49c325868..1ab372443 100644 --- a/backbone.js +++ b/backbone.js @@ -1476,11 +1476,11 @@ // order of the routes here to support behavior where the most general // routes can be defined at the bottom of the route map. _bindRoutes: function() { + var router = this; var routes = _.result(this, 'routes'); - if (!routes) return; - for (var route in routes) { - this.route(route, routes[route]); - } + _.reduceRight(routes, function(_, callback, route) { + router.route(route, callback); + }, void 0); }, // Convert a route string into a regular expression, suitable for matching diff --git a/test/router.js b/test/router.js index db2db909c..8cb0f38f3 100644 --- a/test/router.js +++ b/test/router.js @@ -657,7 +657,7 @@ }); var router = new RouterExtended(); - deepEqual({home: "root", index: "index.html", show: "show", search: "search"}, router.routes); + deepEqual({home: "root", index: "index.html", show: "show", search: "search"}, router.routes()); }); test("#2538 - hashChange to pushState only if both requested.", 0, function() {