Skip to content

Commit 7bc88f3

Browse files
committedFeb 6, 2019
fix: skip microtask fix in Firefix <= 53
fix #9446
1 parent 96a09aa commit 7bc88f3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed
 

‎src/core/util/env.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform ===
1515
export const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios')
1616
export const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge
1717
export const isPhantomJS = UA && /phantomjs/.test(UA)
18+
export const isFF = UA && UA.match(/firefox\/(\d+)/)
1819

1920
// Firefox has a "watch" function on Object.prototype...
2021
export const nativeWatch = ({}).watch

‎src/platforms/web/runtime/modules/events.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { isDef, isUndef } from 'shared/util'
44
import { updateListeners } from 'core/vdom/helpers/index'
5-
import { isIE, supportsPassive, isUsingMicroTask } from 'core/util/index'
5+
import { isIE, isFF, supportsPassive, isUsingMicroTask } from 'core/util/index'
66
import { RANGE_TOKEN, CHECKBOX_RADIO_TOKEN } from 'web/compiler/directives/model'
77
import { currentFlushTimestamp } from 'core/observer/scheduler'
88

@@ -39,6 +39,11 @@ function createOnceHandler (event, handler, capture) {
3939
}
4040
}
4141

42+
// #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
43+
// implementation and does not fire microtasks in between event propagation, so
44+
// safe to exclude.
45+
const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53)
46+
4247
function add (
4348
name: string,
4449
handler: Function,
@@ -51,7 +56,7 @@ function add (
5156
// the solution is simple: we save the timestamp when a handler is attached,
5257
// and the handler would only fire if the event passed to it was fired
5358
// AFTER it was attached.
54-
if (isUsingMicroTask) {
59+
if (useMicrotaskFix) {
5560
const attachedTimestamp = currentFlushTimestamp
5661
const original = handler
5762
handler = original._wrapper = function (e) {

0 commit comments

Comments
 (0)