window.onpopstate is null error in fire()#229
Open
staeke wants to merge 5 commits intoflatiron:masterfrom
Open
window.onpopstate is null error in fire()#229staeke wants to merge 5 commits intoflatiron:masterfrom
staeke wants to merge 5 commits intoflatiron:masterfrom
Conversation
added 2 commits
April 1, 2014 11:35
…Route called before onpopstate is set. When fire is triggered (e.g. through setRoute) an error occurs if we haven't set onpopstate. Thus, make sure to record any fire calls, set onpopstate as soon as DOM is ready (+1 event loop), and then resume, possibly triggering a recorded fire
Author
|
Did you guys have an opinion on this. Would appreciate either a merge or a comment. |
Contributor
|
Hey @staeke, I'm helping to maintain this library now. Do you have an example of how to reproduce the undesired behavior? I can help to create a test case if so and then will work to get this merged. |
…y quickly after first router initialisation.
|
@beaugunderson I have also had problems caused by this so thought I'd contribute. See staeke#1 for a test that will both demonstrate the problem and the efficacy of the solution proposed by @staeke |
Unit test to demonstrate onpopstate failure when navigating very quickly
|
I'm encountering this in mobile Safari as well when |
|
I fixed this one a little differently: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Better handling of cases where there's a race condition on start, setRoute called before onpopstate is set. When fire is triggered (e.g. through setRoute) an error occurs if we haven't set onpopstate. Thus, make sure to record any fire calls, set onpopstate as soon as DOM is ready (+1 event loop), and then resume, possibly triggering a recorded fire call.