Skip to content

Commit 64fc3bb

Browse files
felixbuenemannkiku-jw
authored andcommitted
fix(scheduler): fix getNow check in IE9 (vuejs#9647)
fix vuejs#9632
1 parent 89606da commit 64fc3bb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/core/observer/scheduler.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ let getNow: () => number = Date.now
4747
// timestamp can either be hi-res (relative to page load) or low-res
4848
// (relative to UNIX epoch), so in order to compare time we have to use the
4949
// same timestamp type when saving the flush timestamp.
50-
if (inBrowser && getNow() > document.createEvent('Event').timeStamp) {
51-
// if the low-res timestamp which is bigger than the event timestamp
52-
// (which is evaluated AFTER) it means the event is using a hi-res timestamp,
53-
// and we need to use the hi-res version for event listeners as well.
50+
if (
51+
inBrowser &&
52+
window.performance &&
53+
typeof performance.now === 'function' &&
54+
getNow() > document.createEvent('Event').timeStamp
55+
) {
56+
// if the event timestamp is bigger than the hi-res timestamp
57+
// (which is evaluated AFTER) it means the event is using a lo-res timestamp,
58+
// and we need to use the lo-res version for event listeners as well.
5459
getNow = () => performance.now()
5560
}
5661

0 commit comments

Comments
 (0)