Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-dom): fix the event listeners call in firefox <= 53 #3501

Merged
merged 2 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/runtime-dom/src/modules/events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hyphenate, isArray } from '@vue/shared'
import { hyphenate, isArray, isFF } from '@vue/shared'
Copy link
Member

Choose a reason for hiding this comment

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

since isFF isn't actually used anywhere else, and it being very version specific, let's just keep the detection logic here instead of in @vue/shared. Can also directly a variable named bailTimestampCheck.

Choose a reason for hiding this comment

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

@yyx990803 Firefox isn't the only platform that is affected by this. See this 2.6 PR for more.

import {
ComponentInternalInstance,
callWithAsyncErrorHandling
Expand Down Expand Up @@ -111,7 +111,13 @@ function createInvoker(
// and the handler would only fire if the event passed to it was fired
// AFTER it was attached.
const timeStamp = e.timeStamp || _getNow()
if (timeStamp >= invoker.attached - 1) {

if (
timeStamp >= invoker.attached - 1 ||
// #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
// and does not fire microtasks in between event propagation, so safe to exclude.
(isFF && Number(isFF[1]) <= 53)
) {
callWithAsyncErrorHandling(
patchStopImmediatePropagation(e, invoker.value),
instance,
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,7 @@ export const getGlobalThis = (): any => {
: {})
)
}

const UA =
typeof window !== 'undefined' && window.navigator.userAgent.toLowerCase()
export const isFF = UA && UA.match(/firefox\/(\d+)/)