1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Handles the initial popstate event of older version of Safari. (#870)

This commit is contained in:
Arunoda Susiripala 2017-01-25 08:58:26 -08:00 committed by Naoyuki Kanezawa
parent f89eaf315c
commit b4e2b7bd4d

View file

@ -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)) {