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

mobile safari triggers Router.run twice on initial page load #753

Closed
bmcmahen opened this issue Feb 1, 2015 · 6 comments
Closed

mobile safari triggers Router.run twice on initial page load #753

bmcmahen opened this issue Feb 1, 2015 · 6 comments
Labels

Comments

@bmcmahen
Copy link

bmcmahen commented Feb 1, 2015

I haven't had too much time to test this in other contexts, but within my app I've noticed that on the initial page load Router.run is triggered twice on the initial page load -- both times with the same state / route information. I haven't noticed this happening in any other browsers. As a quick fix, I've stored the current route information and done the relevant checks to determine if it has, indeed, changed.

@ryanflorence
Copy link
Member

interesting, let us know if you discover anything else.

@mjackson
Copy link
Member

I think this is a WebKit bug. See

https://bugs.webkit.org/show_bug.cgi?id=93506
https://bugs.webkit.org/show_bug.cgi?id=80697

@bmcmahen Are you using HistoryLocation by any chance? That bug is specific to using the HTML5 history API.

Also, Twitter worked around this bug by ignoring popstate events when the state property is undefined.

@bmcmahen
Copy link
Author

Yep, I was using HistoryLocation. I haven't been able to explore the issue all that much more, but I have only encountered it while using mobile safari with HistoryLocation.

@mjackson
Copy link
Member

@bmcmahen Thanks for confirming. I'm just going to assume we're running into the same bug that Twitter was for now. Please let us know if you still see this behavior when using 3d8a883.

@dlindenkreuz
Copy link
Contributor

Still getting onPopState event on initial page load with Safari 8.0.6.

Check should be changed from if (event.state === undefined) to if (event.state === null). Apparently, the state property is never undefined.

@ryanzec
Copy link

ryanzec commented Sep 1, 2015

I think this needs to be re-opened as I am still seeing this issue. Following @dlindenkreuz suggestion, I changes that if to:

if (event.state === undefined || event.state === null) {
 return;
}

and it seems to work in safari after that.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants