Skip to content

Commit

Permalink
fix(scheduler): revert timeStamp check
Browse files Browse the repository at this point in the history
fix vuejs#9729

This reverts vuejs#9667, but also fixes the original issue vuejs#9632 by skipping
the check in IE altogether (since all IE use low-res event timestamps).
  • Loading branch information
yyx990803 authored and Lostlover committed Dec 10, 2019
1 parent 79821c0 commit 9f4c380
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/core/observer/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
warn,
nextTick,
devtools,
inBrowser
inBrowser,
isIE
} from '../util/index'

export const MAX_UPDATE_COUNT = 100
Expand Down Expand Up @@ -47,16 +48,19 @@ 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) {
// All IE versions use low-res event timestamps, and have problematic clock
// implementations (#9632)
if (inBrowser && !isIE) {
const performance = window.performance
if (
performance &&
typeof performance.now === 'function' &&
document.createEvent('Event').timeStamp <= performance.now()
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.
// if the event timestamp, although evaluated AFTER the Date.now(), is
// smaller than it, it means the event is using a hi-res timestamp,
// and we need to use the hi-res version for event listener timestamps as
// well.
getNow = () => performance.now()
}
}
Expand Down

0 comments on commit 9f4c380

Please sign in to comment.