From 60a5e6edd853cfb67ddeb4a563a195725561ae9e Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Sat, 23 May 2015 22:16:36 -0400 Subject: [PATCH] Do not overwrite this.routes in #_bindRoutes --- backbone.js | 9 ++++----- test/router.js | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/backbone.js b/backbone.js index b16499a6a..4c0ac9e2a 100644 --- a/backbone.js +++ b/backbone.js @@ -1477,11 +1477,10 @@ // 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() { - if (!this.routes) return; - this.routes = _.result(this, 'routes'); - var route, routes = _.keys(this.routes); - while ((route = routes.pop()) != null) { - this.route(route, this.routes[route]); + var routes = _.result(this, 'routes'); + var keys = _.keys(routes); + for (var i = keys.length - 1; i >= 0; i--) { + this.route(keys[i], routes[keys[i]]); } }, diff --git a/test/router.js b/test/router.js index 324ed07f2..e6eee2d7a 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() {