Skip to content

Commit 1961d35

Browse files
Declan de Wetyyx990803
authored andcommitted
make use of user timing api if available (vuejs#998)
1 parent 473b25d commit 1961d35

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/history/html5.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import type VueRouter from '../index'
44
import { assert } from '../util/warn'
5+
import { inBrowser } from '../util/dom'
56
import { cleanPath } from '../util/path'
67
import { History } from './base'
78
import {
@@ -12,7 +13,10 @@ import {
1213
getElementPosition
1314
} from '../util/scroll-position'
1415

15-
const genKey = () => String(Date.now())
16+
// use User Timing api (if present) for more accurate key precision
17+
const Time = inBrowser ? (window.performance || Date) : Date
18+
19+
const genKey = () => String(Time.now())
1620
let _key: string = genKey()
1721

1822
export class HTML5History extends History {

0 commit comments

Comments
 (0)