Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also use pageshow event as URL change cue #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lmorchard
Copy link

In some navigation cases, the popstate event is not fired when URL
navigation happens. But, pageshow is. So, use that event as an
additional URL change cue.

In some navigation cases, the `popstate` event is not fired when URL
navigation happens. But, `pageshow` is. So, use that event as an
additional URL change cue.
@wraithgar
Copy link
Contributor

Do we need both? Is pageshow more appropriate? A quick read of the description suggests we may be able to do this but it would need to be tested.

@lmorchard
Copy link
Author

Honestly, I'm still trying to wrap my head around when each of these events fire across browsers. This fixed a bug for me, but it smells like a hack. I figured it's okay for now, because checkUrl stops duplicate work from happening if both popstate and pageshow both fire.

To reproduce the bug I was seeing, I did this in my app on Firefox:

  • Load a page, navigate to another.
  • Go to the URL bar, hit enter. The page reloads. (Just hitting the reload button doesn't do it)
  • Navigate backward - nothing happens, because the popstate event doesn't fire. (But pageshow does)

What I haven't figured out yet is if pageshow fires at all the interesting times, and could be used to entirely replace popstate

@wraithgar
Copy link
Contributor

Leaving both in would probably result in a lot of double-fires of the loadUrl method which is not good imo. And yes it looks like Firefox has popstate issues as per https://developer.mozilla.org/en-US/docs/Web/Events/popstate

Browsers tend to handle the popstate event differently on page load. Chrome (prior to v34) and Safari always emit a popstate event on page load, but Firefox doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants