]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-dom/v-on): only block event handlers based on attach timestamp
authorEvan You <yyx990803@gmail.com>
Mon, 13 Jul 2020 18:49:54 +0000 (14:49 -0400)
committerEvan You <yyx990803@gmail.com>
Mon, 13 Jul 2020 18:50:11 +0000 (14:50 -0400)
fix #1565

packages/runtime-dom/src/modules/events.ts

index f146a3f8f6ed9da76dfe29fa3443aec432efcb15..553816c9f030d39bec33f55ff551625b2c587836 100644 (file)
@@ -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
 }