Skip to content

Commit

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

This reverts #9667, but also fixes the original issue #9632 by skipping
the check in IE altogether (since all IE use low-res event timestamps).
  • Loading branch information
yyx990803 committed Mar 19, 2019
1 parent ebc1893 commit 22790b2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/core/observer/scheduler.js
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

1 comment on commit 22790b2

@zhangyuang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

。。。刚好发现这个问题,导致uc上click事件失效,他们降低了performance.now的精度

Please sign in to comment.