Skip to content

Commit 60a5e6e

Browse files
committed
Do not overwrite this.routes in #_bindRoutes
1 parent 5f871af commit 60a5e6e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

backbone.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,11 +1477,10 @@
14771477
// order of the routes here to support behavior where the most general
14781478
// routes can be defined at the bottom of the route map.
14791479
_bindRoutes: function() {
1480-
if (!this.routes) return;
1481-
this.routes = _.result(this, 'routes');
1482-
var route, routes = _.keys(this.routes);
1483-
while ((route = routes.pop()) != null) {
1484-
this.route(route, this.routes[route]);
1480+
var routes = _.result(this, 'routes');
1481+
var keys = _.keys(routes);
1482+
for (var i = keys.length - 1; i >= 0; i--) {
1483+
this.route(keys[i], routes[keys[i]]);
14851484
}
14861485
},
14871486

test/router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@
657657
});
658658

659659
var router = new RouterExtended();
660-
deepEqual({home: "root", index: "index.html", show: "show", search: "search"}, router.routes);
660+
deepEqual({home: "root", index: "index.html", show: "show", search: "search"}, router.routes());
661661
});
662662

663663
test("#2538 - hashChange to pushState only if both requested.", 0, function() {

0 commit comments

Comments
 (0)