Răsfoiți Sursa

fix: skip microtask fix in Firefix <= 53

fix #9446
Evan You 7 ani în urmă
părinte
comite
7bc88f30c3
2 a modificat fișierele cu 8 adăugiri și 2 ștergeri
  1. 1 0
      src/core/util/env.js
  2. 7 2
      src/platforms/web/runtime/modules/events.js

+ 1 - 0
src/core/util/env.js

@@ -15,6 +15,7 @@ export const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform ===
 export const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios')
 export const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge
 export const isPhantomJS = UA && /phantomjs/.test(UA)
+export const isFF = UA && UA.match(/firefox\/(\d+)/)
 
 // Firefox has a "watch" function on Object.prototype...
 export const nativeWatch = ({}).watch

+ 7 - 2
src/platforms/web/runtime/modules/events.js

@@ -2,7 +2,7 @@
 
 import { isDef, isUndef } from 'shared/util'
 import { updateListeners } from 'core/vdom/helpers/index'
-import { isIE, supportsPassive, isUsingMicroTask } from 'core/util/index'
+import { isIE, isFF, supportsPassive, isUsingMicroTask } from 'core/util/index'
 import { RANGE_TOKEN, CHECKBOX_RADIO_TOKEN } from 'web/compiler/directives/model'
 import { currentFlushTimestamp } from 'core/observer/scheduler'
 
@@ -39,6 +39,11 @@ function createOnceHandler (event, handler, capture) {
   }
 }
 
+// #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
+// implementation and does not fire microtasks in between event propagation, so
+// safe to exclude.
+const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53)
+
 function add (
   name: string,
   handler: Function,
@@ -51,7 +56,7 @@ function add (
   // the solution is simple: we save the timestamp when a handler is attached,
   // and the handler would only fire if the event passed to it was fired
   // AFTER it was attached.
-  if (isUsingMicroTask) {
+  if (useMicrotaskFix) {
     const attachedTimestamp = currentFlushTimestamp
     const original = handler
     handler = original._wrapper = function (e) {