From 35f67a508fa1930fd90ee05027522c5492fdc4e1 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Fri, 8 Apr 2022 16:08:26 +0800 Subject: [PATCH] fix(mp): revert invalidateJob (#3408) --- .../uni-mp-core/src/runtime/componentOptions.ts | 9 +++++++-- packages/uni-mp-vue/lib/vue.runtime.esm.js | 14 ++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/uni-mp-core/src/runtime/componentOptions.ts b/packages/uni-mp-core/src/runtime/componentOptions.ts index af7178a80..4db38c0d6 100644 --- a/packages/uni-mp-core/src/runtime/componentOptions.ts +++ b/packages/uni-mp-core/src/runtime/componentOptions.ts @@ -60,8 +60,13 @@ export function updateComponentProps( const nextProps = findComponentPropsData(up) || {} if (hasPropsChanged(prevProps, nextProps)) { updateProps(instance, nextProps, prevProps, false) - invalidateJob(instance.update) - instance.update() + const index = invalidateJob(instance.update) + if (__PLATFORM__ === 'mp-toutiao') { + // 字节跳动小程序 https://github.com/dcloudio/uni-app/issues/3340 + index === -1 && instance.update() + } else { + instance.update() + } } } diff --git a/packages/uni-mp-vue/lib/vue.runtime.esm.js b/packages/uni-mp-vue/lib/vue.runtime.esm.js index 5f20a93dc..b7247324e 100644 --- a/packages/uni-mp-vue/lib/vue.runtime.esm.js +++ b/packages/uni-mp-vue/lib/vue.runtime.esm.js @@ -1413,6 +1413,14 @@ function queueFlush() { currentFlushPromise = resolvedPromise.then(flushJobs); } } +function invalidateJob(job) { + const i = queue.indexOf(job); + if (i > flushIndex) { + queue.splice(i, 1); + } + // fixed by xxxxxx + return i; +} function queueCb(cb, activeQueue, pendingQueue, index) { if (!isArray(cb)) { if (!activeQueue || @@ -4428,12 +4436,6 @@ function unwrapper(target) { } function defineAsyncComponent(source) { console.error('defineAsyncComponent is unsupported'); -} -function invalidateJob(job) { - const i = queue.indexOf(job); - if (i > -1) { - queue.splice(i, 1); - } } // import deepCopy from './deepCopy' -- GitLab