From b4e2b7bd4d3d7470e4037a506ea9fd8e0332f6dd Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Wed, 25 Jan 2017 08:58:26 -0800 Subject: [PATCH] Handles the initial popstate event of older version of Safari. (#870) --- lib/router/router.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/router/router.js b/lib/router/router.js index a8f042e6..8ac70844 100644 --- a/lib/router/router.js +++ b/lib/router/router.js @@ -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)) {