File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 3
3
import type Router from '../index'
4
4
import { History } from './base'
5
5
import { cleanPath } from '../util/path'
6
+ import { START } from '../util/route'
6
7
import { setupScroll , handleScroll } from '../util/scroll'
7
8
import { pushState , replaceState } from '../util/push-state'
8
9
@@ -16,9 +17,18 @@ export class HTML5History extends History {
16
17
setupScroll ( )
17
18
}
18
19
20
+ const initLocation = getLocation ( this . base )
19
21
window . addEventListener ( 'popstate' , e => {
20
22
const current = this . current
21
- this . transitionTo ( getLocation ( this . base ) , route => {
23
+
24
+ // Avoiding first `popstate` event dispatched in some browsers but first
25
+ // history route not updated since async guard at the same time.
26
+ const location = getLocation ( this . base )
27
+ if ( this . current === START && location === initLocation ) {
28
+ return
29
+ }
30
+
31
+ this . transitionTo ( location , route => {
22
32
if ( expectScroll ) {
23
33
handleScroll ( router , route , current , true )
24
34
}
You can’t perform that action at this time.
0 commit comments