Permalink
Browse files

Make sure `History` works even if `root` isn't `window`

If Backbone is called from a different `this` context than `window`,
`root.location` and `root.history` will fail.

This fix is important for Browserify compatibility.
  • Loading branch information...
1 parent e809bfb commit c798d7226d071a0cb99a82321334fe250fe9e7e9 @jacobrask jacobrask committed Sep 16, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 backbone.js
View
@@ -961,8 +961,8 @@
var History = Backbone.History = function(options) {
this.handlers = [];
_.bindAll(this, 'checkUrl');
- this.location = options && options.location || root.location;
- this.history = options && options.history || root.history;
+ this.location = options && options.location || root.location || window.location;
+ this.history = options && options.history || root.history || window.history;
};
// Cached regex for cleaning leading hashes and slashes.

0 comments on commit c798d72

Please sign in to comment.