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

Handles the initial popstate event of older version of Safari #870

Merged
merged 2 commits into from
Jan 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@ export default class Router extends EventEmitter {
}

async onPopState (e) {
// Older versions of safari and chrome tend to fire popstate event at the
// page load.
// We should not complete that event and the following check will fix it.
// Fixes:
if (!e.state) {
return
}

this.abortComponentLoad()

const { url = getURL(), as = url } = e.state || {}
const { url, as } = e.state
const { pathname, query } = parse(url, true)

if (!this.urlIsNew(pathname, query)) {
Expand Down