From 42942fb4f0bb6407b39dc17533ad9228d17d8c11 Mon Sep 17 00:00:00 2001 From: semiaddict Date: Wed, 23 Feb 2022 11:29:09 +0100 Subject: [PATCH] fix(runtime-dom): allow opting out from events timestamp check close #2513 #3933 --- packages/runtime-core/src/apiCreateApp.ts | 4 +++- packages/runtime-dom/src/modules/events.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/runtime-core/src/apiCreateApp.ts b/packages/runtime-core/src/apiCreateApp.ts index ae2f58418dc..326e5230e70 100644 --- a/packages/runtime-core/src/apiCreateApp.ts +++ b/packages/runtime-core/src/apiCreateApp.ts @@ -81,6 +81,7 @@ export interface AppConfig { instance: ComponentPublicInstance | null, trace: string ) => void + skipEventsTimestampCheck: boolean /** * Options to pass to `@vue/compiler-dom`. @@ -155,7 +156,8 @@ export function createAppContext(): AppContext { optionMergeStrategies: {}, errorHandler: undefined, warnHandler: undefined, - compilerOptions: {} + compilerOptions: {}, + skipEventsTimestampCheck: false }, mixins: [], components: {}, diff --git a/packages/runtime-dom/src/modules/events.ts b/packages/runtime-dom/src/modules/events.ts index 51544dedf49..701ce815189 100644 --- a/packages/runtime-dom/src/modules/events.ts +++ b/packages/runtime-dom/src/modules/events.ts @@ -117,7 +117,10 @@ function createInvoker( // AFTER it was attached. const timeStamp = e.timeStamp || _getNow() - if (skipTimestampCheck || timeStamp >= invoker.attached - 1) { + // Skip the timestamp check if the skipEventsTimestampCheck app config is set to true. + const appSkipTimestampCheck = instance?.appContext?.config.skipEventsTimestampCheck === true + + if (appSkipTimestampCheck || skipTimestampCheck || timeStamp >= invoker.attached - 1) { callWithAsyncErrorHandling( patchStopImmediatePropagation(e, invoker.value), instance,