|
2 | 2 |
|
3 | 3 | import { isDef, isUndef } from 'shared/util' |
4 | 4 | import { updateListeners } from 'core/vdom/helpers/index' |
5 | | -import { isIE, isChrome, supportsPassive } from 'core/util/index' |
| 5 | +import { isIE, supportsPassive, isUsingMicroTask } from 'core/util/index' |
6 | 6 | import { RANGE_TOKEN, CHECKBOX_RADIO_TOKEN } from 'web/compiler/directives/model' |
| 7 | +import { currentFlushTimestamp } from 'core/observer/scheduler' |
7 | 8 |
|
8 | 9 | // normalize v-model event tokens that can only be determined at runtime. |
9 | 10 | // it's important to place the event as the first in the array because |
@@ -44,17 +45,17 @@ function add ( |
44 | 45 | capture: boolean, |
45 | 46 | passive: boolean |
46 | 47 | ) { |
47 | | - if (isChrome) { |
48 | | - // async edge case #6566: inner click event triggers patch, event handler |
49 | | - // attached to outer element during patch, and triggered again. This only |
50 | | - // happens in Chrome as it fires microtask ticks between event propagation. |
51 | | - // the solution is simple: we save the timestamp when a handler is attached, |
52 | | - // and the handler would only fire if the event passed to it was fired |
53 | | - // AFTER it was attached. |
54 | | - const now = performance.now() |
| 48 | + // async edge case #6566: inner click event triggers patch, event handler |
| 49 | + // attached to outer element during patch, and triggered again. This only |
| 50 | + // happens in Chrome as it fires microtask ticks between event propagation. |
| 51 | + // the solution is simple: we save the timestamp when a handler is attached, |
| 52 | + // and the handler would only fire if the event passed to it was fired |
| 53 | + // AFTER it was attached. |
| 54 | + if (isUsingMicroTask) { |
| 55 | + const attachedTimestamp = currentFlushTimestamp |
55 | 56 | const original = handler |
56 | 57 | handler = original._wrapper = function (e) { |
57 | | - if (e.timeStamp >= now) { |
| 58 | + if (e.timeStamp >= attachedTimestamp) { |
58 | 59 | return original.apply(this, arguments) |
59 | 60 | } |
60 | 61 | } |
|
0 commit comments