diff --git a/packages/uni-mp-vue/dist/vue.runtime.esm.js b/packages/uni-mp-vue/dist/vue.runtime.esm.js index 99be1dd0a1184d778cb44983284e596da2e50a23..c85d96a032cec1137f8cb59c80e61a96ef8567f9 100644 --- a/packages/uni-mp-vue/dist/vue.runtime.esm.js +++ b/packages/uni-mp-vue/dist/vue.runtime.esm.js @@ -1407,27 +1407,10 @@ function queueJob(job) { queueFlush(); } } -// fixed by xxxxxx -let delayFlushJobs = false; -function setDelayFlushJobs(isDelay) { - delayFlushJobs = isDelay; -} -// fixed by xxxxxx -function sleep(ms) { - return () => { - return new Promise(resolve => setTimeout(() => resolve(void 0), ms)); - }; -} function queueFlush() { if (!isFlushing && !isFlushPending) { isFlushPending = true; - if (delayFlushJobs) { - // fixed by xxxxxx 延迟执行,避免同一批次的事件执行时机不正确,对性能可能有略微影响 https://github.com/dcloudio/uni-app/issues/3228 - currentFlushPromise = resolvedPromise.then(sleep(0)).then(flushJobs); - } - else { - currentFlushPromise = resolvedPromise.then(flushJobs); - } + currentFlushPromise = resolvedPromise.then(flushJobs); } } function invalidateJob(job) { @@ -1506,8 +1489,6 @@ function flushPostFlushCbs(seen) { } const getId = (job) => job.id == null ? Infinity : job.id; function flushJobs(seen) { - // fixed by xxxxxx - delayFlushJobs = false; isFlushPending = false; isFlushing = true; if ((process.env.NODE_ENV !== 'production')) { @@ -5364,7 +5345,17 @@ function createInvoker(initialValue, instance) { if (e.detail && e.detail.__args__) { args = e.detail.__args__; } - callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, args); + const eventValue = invoker.value; + const invoke = () => { + callWithAsyncErrorHandling(patchStopImmediatePropagation(e, eventValue), instance, 5 /* NATIVE_EVENT_HANDLER */, args); + }; + // 冒泡事件触发时,启用延迟策略,避免同一批次的事件执行时机不正确,对性能可能有略微影响 https://github.com/dcloudio/uni-app/issues/3228 + if (bubbles.includes(e.type)) { + setTimeout(invoke); + } + else { + invoke(); + } }; invoker.value = initialValue; return invoker; @@ -5386,10 +5377,6 @@ const bubbles = [ ]; function patchMPEvent(event) { if (event.type && event.target) { - // 冒泡事件触发时,启用延迟策略,避免同一批次的事件执行时机不正确,对性能可能有略微影响 https://github.com/dcloudio/uni-app/issues/3228 - if (bubbles.includes(event.type)) { - setDelayFlushJobs(true); - } event.preventDefault = NOOP; event.stopPropagation = NOOP; event.stopImmediatePropagation = NOOP; @@ -5583,4 +5570,4 @@ function createApp(rootComponent, rootProps = null) { } const createSSRApp = createApp; -export { EffectScope, Fragment, ReactiveEffect, Text, c, callWithAsyncErrorHandling, callWithErrorHandling, computed$1 as computed, createApp, createSSRApp, createVNode$1 as createVNode, createVueApp, customRef, d, defineAsyncComponent, defineComponent, defineEmits, defineExpose, defineProps, diff, e, effect, effectScope, f, findComponentPropsData, getCurrentInstance, getCurrentScope, getExposeProxy, guardReactiveProps, h, inject, injectHook, invalidateJob, isInSSRComponentSetup, isProxy, isReactive, isReadonly, isRef, logError, markRaw, mergeDefaults, mergeProps, n, nextTick, o, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, p, patch, provide, proxyRefs, pruneComponentPropsCache, queuePostFlushCb, r, reactive, readonly, ref, resolveComponent, resolveDirective, resolveFilter, s, setCurrentRenderingInstance, setDelayFlushJobs, setTemplateRef, setupDevtoolsPlugin, shallowReactive, shallowReadonly, shallowRef, sr, stop, t, toHandlers, toRaw, toRef, toRefs, triggerRef, unref, updateProps, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, version, w, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withModifiers, withScopeId }; +export { EffectScope, Fragment, ReactiveEffect, Text, c, callWithAsyncErrorHandling, callWithErrorHandling, computed$1 as computed, createApp, createSSRApp, createVNode$1 as createVNode, createVueApp, customRef, d, defineAsyncComponent, defineComponent, defineEmits, defineExpose, defineProps, diff, e, effect, effectScope, f, findComponentPropsData, getCurrentInstance, getCurrentScope, getExposeProxy, guardReactiveProps, h, inject, injectHook, invalidateJob, isInSSRComponentSetup, isProxy, isReactive, isReadonly, isRef, logError, markRaw, mergeDefaults, mergeProps, n, nextTick, o, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, p, patch, provide, proxyRefs, pruneComponentPropsCache, queuePostFlushCb, r, reactive, readonly, ref, resolveComponent, resolveDirective, resolveFilter, s, setCurrentRenderingInstance, setTemplateRef, setupDevtoolsPlugin, shallowReactive, shallowReadonly, shallowRef, sr, stop, t, toHandlers, toRaw, toRef, toRefs, triggerRef, unref, updateProps, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, version, w, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withModifiers, withScopeId }; diff --git a/packages/uni-mp-vue/lib/vue.runtime.esm.js b/packages/uni-mp-vue/lib/vue.runtime.esm.js index bff250a8fb20df33c6a077fe2b68dced2e53c3f9..fe148d18e7c28bae75f2014a265eb561a88db321 100644 --- a/packages/uni-mp-vue/lib/vue.runtime.esm.js +++ b/packages/uni-mp-vue/lib/vue.runtime.esm.js @@ -1407,27 +1407,10 @@ function queueJob(job) { queueFlush(); } } -// fixed by xxxxxx -let delayFlushJobs = false; -function setDelayFlushJobs(isDelay) { - delayFlushJobs = isDelay; -} -// fixed by xxxxxx -function sleep(ms) { - return () => { - return new Promise(resolve => setTimeout(() => resolve(void 0), ms)); - }; -} function queueFlush() { if (!isFlushing && !isFlushPending) { isFlushPending = true; - if (delayFlushJobs) { - // fixed by xxxxxx 延迟执行,避免同一批次的事件执行时机不正确,对性能可能有略微影响 https://github.com/dcloudio/uni-app/issues/3228 - currentFlushPromise = resolvedPromise.then(sleep(0)).then(flushJobs); - } - else { - currentFlushPromise = resolvedPromise.then(flushJobs); - } + currentFlushPromise = resolvedPromise.then(flushJobs); } } function invalidateJob(job) { @@ -1506,8 +1489,6 @@ function flushPostFlushCbs(seen) { } const getId = (job) => job.id == null ? Infinity : job.id; function flushJobs(seen) { - // fixed by xxxxxx - delayFlushJobs = false; isFlushPending = false; isFlushing = true; if ((process.env.NODE_ENV !== 'production')) { @@ -5117,4 +5098,4 @@ function initCssVarsRender(instance, getter) { function withModifiers() { } function createVNode$1() { } -export { EffectScope, Fragment, ReactiveEffect, Text, callWithAsyncErrorHandling, callWithErrorHandling, computed$1 as computed, createVNode$1 as createVNode, createVueApp, customRef, defineAsyncComponent, defineComponent, defineEmits, defineExpose, defineProps, diff, effect, effectScope, getCurrentInstance, getCurrentScope, getExposeProxy, guardReactiveProps, inject, injectHook, invalidateJob, isInSSRComponentSetup, isProxy, isReactive, isReadonly, isRef, logError, markRaw, mergeDefaults, mergeProps, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, patch, provide, proxyRefs, queuePostFlushCb, reactive, readonly, ref, resolveComponent, resolveDirective, resolveFilter, setCurrentRenderingInstance, setDelayFlushJobs, setTemplateRef, shallowReactive, shallowReadonly, shallowRef, stop, toHandlers, toRaw, toRef, toRefs, triggerRef, unref, updateProps, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withModifiers, withScopeId }; +export { EffectScope, Fragment, ReactiveEffect, Text, callWithAsyncErrorHandling, callWithErrorHandling, computed$1 as computed, createVNode$1 as createVNode, createVueApp, customRef, defineAsyncComponent, defineComponent, defineEmits, defineExpose, defineProps, diff, effect, effectScope, getCurrentInstance, getCurrentScope, getExposeProxy, guardReactiveProps, inject, injectHook, invalidateJob, isInSSRComponentSetup, isProxy, isReactive, isReadonly, isRef, logError, markRaw, mergeDefaults, mergeProps, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, patch, provide, proxyRefs, queuePostFlushCb, reactive, readonly, ref, resolveComponent, resolveDirective, resolveFilter, setCurrentRenderingInstance, setTemplateRef, shallowReactive, shallowReadonly, shallowRef, stop, toHandlers, toRaw, toRef, toRefs, triggerRef, unref, updateProps, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withModifiers, withScopeId }; diff --git a/packages/uni-mp-vue/src/helpers/vOn.ts b/packages/uni-mp-vue/src/helpers/vOn.ts index 640ac1f44e37e93a73016dc1be02b2938b3b6470..9f979eb2ed03b1dc3300c560754a550894650e18 100644 --- a/packages/uni-mp-vue/src/helpers/vOn.ts +++ b/packages/uni-mp-vue/src/helpers/vOn.ts @@ -12,8 +12,6 @@ import { ErrorCodes, getCurrentInstance, } from 'vue' -// @ts-expect-error -import { setDelayFlushJobs } from 'vue' type EventValue = Function | Function[] @@ -77,12 +75,21 @@ function createInvoker( if ((e as MPEvent).detail && (e as MPEvent).detail.__args__) { args = (e as MPEvent).detail.__args__! } - callWithAsyncErrorHandling( - patchStopImmediatePropagation(e, invoker.value), - instance, - ErrorCodes.NATIVE_EVENT_HANDLER, - args - ) + const eventValue = invoker.value + const invoke = () => { + callWithAsyncErrorHandling( + patchStopImmediatePropagation(e, eventValue), + instance, + ErrorCodes.NATIVE_EVENT_HANDLER, + args + ) + } + // 冒泡事件触发时,启用延迟策略,避免同一批次的事件执行时机不正确,对性能可能有略微影响 https://github.com/dcloudio/uni-app/issues/3228 + if (bubbles.includes(e.type)) { + setTimeout(invoke) + } else { + invoke() + } } invoker.value = initialValue return invoker @@ -104,10 +111,6 @@ const bubbles = [ ] function patchMPEvent(event: MPEvent) { if (event.type && event.target) { - // 冒泡事件触发时,启用延迟策略,避免同一批次的事件执行时机不正确,对性能可能有略微影响 https://github.com/dcloudio/uni-app/issues/3228 - if (bubbles.includes(event.type)) { - setDelayFlushJobs(true) - } event.preventDefault = NOOP event.stopPropagation = NOOP event.stopImmediatePropagation = NOOP