Skip to content

Commit

Permalink
fix(scheduler): fix getNow check in IE9 (vuejs#9647)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbuenemann authored and kiku-jw committed Jun 18, 2019
1 parent 89606da commit 64fc3bb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/core/observer/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ let getNow: () => number = Date.now
// timestamp can either be hi-res (relative to page load) or low-res
// (relative to UNIX epoch), so in order to compare time we have to use the
// same timestamp type when saving the flush timestamp.
if (inBrowser && getNow() > document.createEvent('Event').timeStamp) {
// if the low-res timestamp which is bigger than the event timestamp
// (which is evaluated AFTER) it means the event is using a hi-res timestamp,
// and we need to use the hi-res version for event listeners as well.
if (
inBrowser &&
window.performance &&
typeof performance.now === 'function' &&
getNow() > document.createEvent('Event').timeStamp
) {
// if the event timestamp is bigger than the hi-res timestamp
// (which is evaluated AFTER) it means the event is using a lo-res timestamp,
// and we need to use the lo-res version for event listeners as well.
getNow = () => performance.now()
}

Expand Down

0 comments on commit 64fc3bb

Please sign in to comment.