diff --git a/packages/runtime-core/src/componentRenderContext.ts b/packages/runtime-core/src/componentRenderContext.ts index 1771d9aa029..fdceab91f27 100644 --- a/packages/runtime-core/src/componentRenderContext.ts +++ b/packages/runtime-core/src/componentRenderContext.ts @@ -1,6 +1,7 @@ +import { ShapeFlags } from 'packages/shared/src/shapeFlags' import { ComponentInternalInstance } from './component' import { isRenderingCompiledSlot } from './helpers/renderSlot' -import { closeBlock, openBlock } from './vnode' +import { closeBlock, openBlock, VNode } from './vnode' /** * mark the current rendering instance for asset resolution (e.g. @@ -68,11 +69,15 @@ export function withCtx( openBlock(true /* null block that disables tracking */) } const prevInstance = setCurrentRenderingInstance(ctx) - const res = fn(...args) + const res: VNode[] = fn(...args) setCurrentRenderingInstance(prevInstance) if (!isRenderingCompiledSlot) { closeBlock() } + // #3569 + if (!isRenderingCompiledSlot && res) { + forceBailout(res) + } return res } // mark this as a compiled slot function. @@ -81,3 +86,16 @@ export function withCtx( renderFnWithContext._c = true return renderFnWithContext } + +function forceBailout(vnodes: VNode[]) { + vnodes.forEach(vnode => { + // when the user manually renders the compiled slot, + // it will be able to easily break the optimization update mode, + // so here we force to exit the optimization mode + vnode.dynamicChildren = null + vnode.patchFlag = 0 + if (vnode.shapeFlag & ShapeFlags.ARRAY_CHILDREN) { + forceBailout(vnode.children as VNode[]) + } + }) +}