Fallback root.location and root.history to window #1653

jacobrask opened this Issue Sep 16, 2012 · 4 comments


None yet
3 participants

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

This is an issue that I encounter when trying to use Backbone with Browserify.

I fixed this for my own purposes in c798d72 but that caused some failing tests due to window is not defined.

Would it be ok with something like var win = typeof window !== 'undefined' ? window : {}; next to the root definition?


jashkenas commented Sep 17, 2012

Why would you be using Backbone with Browserify? Backbone already works in the browser...

Browserify is as much a require.js alternative as it is a Node -> Browser converter.

Some of my code is shared between the browser and Node, which is made easy Browserify (I simply expose my module to module.exports). Browserify also lets me specify dependencies and do updates via npm.

jashkenas added a commit that referenced this issue Sep 17, 2012

Merge pull request #1658 from braddunbar/history-window
Fix #1653 - Ensure that `History` can be used outside of the browser.

braddunbar commented Sep 17, 2012

@jacobrask Addressed in #1658. Please let us know if that doesn't work for you. :)

It works fine, thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment