diff --git a/src/core/component/engines/vue3/render.ts b/src/core/component/engines/vue3/render.ts index 962534c112..d4b2055932 100644 --- a/src/core/component/engines/vue3/render.ts +++ b/src/core/component/engines/vue3/render.ts @@ -123,8 +123,25 @@ export const export const mergeProps = wrapMergeProps(superMergeProps), - renderList = wrapRenderList(superRenderList, superWithCtx), renderSlot = wrapRenderSlot(superRenderSlot); + +export const renderList = wrapRenderList( + superRenderList, + (...args: Parameters) => { + // Vue has two contexts for instances: `currentInstance` and `currentRenderingInstance`. + // The context for the renderList should be a `currentRenderingInstance` because `renderList` is called during component rendering. + const fn = superWithCtx(...args); + + // Enable block tracking + // @see https://github.com/vuejs/core/blob/45984d559fe0c036657d5f2626087ea8eec205a8/packages/runtime-core/src/componentRenderContext.ts#L88 + if ('_d' in fn) { + (fn)._d = false; + } + + return fn; + } +); + export const withCtx = wrapWithCtx(superWithCtx), withDirectives = wrapWithDirectives(superWithDirectives), diff --git a/src/core/component/render/wrappers.ts b/src/core/component/render/wrappers.ts index 07f6153039..8a26d56bed 100644 --- a/src/core/component/render/wrappers.ts +++ b/src/core/component/render/wrappers.ts @@ -261,7 +261,9 @@ export function wrapMergeProps(original: T): T { /** * Wrapper for the component library `renderList` function + * * @param original + * @param withCtx */ export function wrapRenderList(original: T, withCtx: C): T { return Object.cast(function renderList( @@ -270,20 +272,10 @@ export function wrapRenderListwrappedCb)._d = false; - } - this.$emit('[[V_FOR_CB]]', wrappedCb); return original(src, wrappedCb); });