فهرست منبع

fix(scheduler): revert timeStamp check

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).
Evan You 7 سال پیش
والد
کامیت
22790b250c
1فایلهای تغییر یافته به همراه10 افزوده شده و 6 حذف شده
  1. 10 6
      src/core/observer/scheduler.js

+ 10 - 6
src/core/observer/scheduler.js

@@ -8,7 +8,8 @@ import {
   warn,
   nextTick,
   devtools,
-  inBrowser
+  inBrowser,
+  isIE
 } from '../util/index'
 
 export const MAX_UPDATE_COUNT = 100
@@ -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()
   }
 }