Protect against exception when onpopstate/onhashchange are null#217
Protect against exception when onpopstate/onhashchange are null#217steveluscher wants to merge 1 commit intoflatiron:masterfrom steveluscher:patch-1
Conversation
Without this patch, the following will throw an exception:
router = Router(routes)
router.configure({
notfound: function() { router.setRoute('/'); }
});
router.init();
In the early stages of page load, `window.onpopstate` and `window.onhashchange` are `null` (in Chrome, anyway).
|
Erm… actually, this still prevents the handler for |
|
So far as I know, and I've been using director since it was sugarskull, it looks that you should just set the window.location.hash to the route you want. In this case, your code would be: Director will pick this up in the hash onChange event and route on it. |
|
But I suppose this won't work if you're trying to use Director in |
|
No. as far as I know, you'd need to do something like this if you are using history: Considering that IE only started supporting pushState and the related methods in version 10, I'm staying away from history mode for a while longer. I'm not even sure that Director supports pushstate well enough to give you deep linking - for that, you need to change the hash with the third parameter in the above call. |
|
It looks like #229 is also an attempt to fix this issue. |
Without this patch, the following will throw an exception:
In the early stages of page load,
window.onpopstateandwindow.onhashchangearenull(in Chrome, anyway).