fix(runtime-dom/v-on): only block event handlers based on attach timestamp
fix #1565
This commit is contained in:
parent
6b63ba2f45
commit
8b320cc12f
@ -7,7 +7,7 @@ import { ErrorCodes } from 'packages/runtime-core/src/errorHandling'
|
||||
|
||||
interface Invoker extends EventListener {
|
||||
value: EventValue
|
||||
lastUpdated: number
|
||||
attached: number
|
||||
}
|
||||
|
||||
type EventValue = (Function | Function[]) & {
|
||||
@ -103,7 +103,6 @@ export function patchEvent(
|
||||
;(prevValue as EventValue).invoker = null
|
||||
invoker.value = value
|
||||
nextValue.invoker = invoker
|
||||
invoker.lastUpdated = getNow()
|
||||
} else {
|
||||
addEventListener(
|
||||
el,
|
||||
@ -129,7 +128,7 @@ 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.lastUpdated - 1) {
|
||||
if (timeStamp >= invoker.attached - 1) {
|
||||
callWithAsyncErrorHandling(
|
||||
patchStopImmediatePropagation(e, invoker.value),
|
||||
instance,
|
||||
@ -140,7 +139,7 @@ function createInvoker(
|
||||
}
|
||||
invoker.value = initialValue
|
||||
initialValue.invoker = invoker
|
||||
invoker.lastUpdated = getNow()
|
||||
invoker.attached = getNow()
|
||||
return invoker
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user