Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if routes is undefined. I would highly suggest using _.each here TBH as it will support undefined

var keys = _.keys(routes);
for (var i = keys.length - 1; i >= 0; i--) {
this.route(keys[i], routes[keys[i]]);
}
},

Expand Down
2 changes: 1 addition & 1 deletion test/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down