From 683c3c8e6446e98edf1d7ab4550b79e07a714f86 Mon Sep 17 00:00:00 2001 From: huangxueliang Date: Fri, 11 Aug 2017 13:52:12 +0800 Subject: [PATCH 1/4] fix ie9 no history fallback render flash --- src/history/base.js | 8 +++++++- src/history/html5.js | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/history/base.js b/src/history/base.js index 0c90dafa7..d9d812c6c 100644 --- a/src/history/base.js +++ b/src/history/base.js @@ -64,7 +64,9 @@ export class History { transitionTo (location: RawLocation, onComplete?: Function, onAbort?: Function) { const route = this.router.match(location, this.current) this.confirmTransition(route, () => { - this.updateRoute(route) + if (this.shuoldUpdateRoute()) { + this.updateRoute(route) + } onComplete && onComplete(route) this.ensureURL() @@ -190,6 +192,10 @@ export class History { hook && hook(route, prev) }) } + + shuoldUpdateRoute ():boolean { + return true; + } } function normalizeBase (base: ?string): string { diff --git a/src/history/html5.js b/src/history/html5.js index 37163703b..eca5317fc 100644 --- a/src/history/html5.js +++ b/src/history/html5.js @@ -4,7 +4,7 @@ import type Router from '../index' import { History } from './base' import { cleanPath } from '../util/path' import { setupScroll, handleScroll } from '../util/scroll' -import { pushState, replaceState } from '../util/push-state' +import { pushState, replaceState, supportsPushState } from '../util/push-state' export class HTML5History extends History { constructor (router: Router, base: ?string) { @@ -58,6 +58,12 @@ export class HTML5History extends History { getCurrentLocation (): string { return getLocation(this.base) } + + shuoldUpdateRoute (): boolean { + // when is ready and don,t support pushState + // route shouldn't render, it suppose to be regular page jump + return !this.ready || supportsPushState + } } export function getLocation (base: string): string { From 48847c7cce6e5292a49da83a4d59f530e8db8cb0 Mon Sep 17 00:00:00 2001 From: huangxueliang Date: Fri, 11 Aug 2017 14:11:02 +0800 Subject: [PATCH 2/4] fix code style --- src/history/base.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/history/base.js b/src/history/base.js index d9d812c6c..9fd22d499 100644 --- a/src/history/base.js +++ b/src/history/base.js @@ -193,8 +193,8 @@ export class History { }) } - shuoldUpdateRoute ():boolean { - return true; + shuoldUpdateRoute (): boolean { + return true } } From 9ea9885c942acb06def500896ef560973a09d953 Mon Sep 17 00:00:00 2001 From: huangxueliang Date: Fri, 11 Aug 2017 14:19:06 +0800 Subject: [PATCH 3/4] fix typo --- src/history/html5.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/history/html5.js b/src/history/html5.js index eca5317fc..7a170e3ae 100644 --- a/src/history/html5.js +++ b/src/history/html5.js @@ -60,7 +60,7 @@ export class HTML5History extends History { } shuoldUpdateRoute (): boolean { - // when is ready and don,t support pushState + // when is ready and don't support pushState // route shouldn't render, it suppose to be regular page jump return !this.ready || supportsPushState } From 93e47bd2110aa3566fa94391814d97043461df95 Mon Sep 17 00:00:00 2001 From: huangxueliang Date: Fri, 11 Aug 2017 17:04:15 +0800 Subject: [PATCH 4/4] shuoldUpdateRoute -> shouldUpdateRoute --- src/history/base.js | 4 ++-- src/history/html5.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/history/base.js b/src/history/base.js index 9fd22d499..5c32ba186 100644 --- a/src/history/base.js +++ b/src/history/base.js @@ -64,7 +64,7 @@ export class History { transitionTo (location: RawLocation, onComplete?: Function, onAbort?: Function) { const route = this.router.match(location, this.current) this.confirmTransition(route, () => { - if (this.shuoldUpdateRoute()) { + if (this.shouldUpdateRoute()) { this.updateRoute(route) } onComplete && onComplete(route) @@ -193,7 +193,7 @@ export class History { }) } - shuoldUpdateRoute (): boolean { + shouldUpdateRoute (): boolean { return true } } diff --git a/src/history/html5.js b/src/history/html5.js index 7a170e3ae..7b5f4ab27 100644 --- a/src/history/html5.js +++ b/src/history/html5.js @@ -59,7 +59,7 @@ export class HTML5History extends History { return getLocation(this.base) } - shuoldUpdateRoute (): boolean { + shouldUpdateRoute (): boolean { // when is ready and don't support pushState // route shouldn't render, it suppose to be regular page jump return !this.ready || supportsPushState