diff --git a/packages/uni-mp-compiler/__tests__/slot.spec.ts b/packages/uni-mp-compiler/__tests__/slot.spec.ts index 75d0573000541e72199fac4c5cb2fe76067bb178..c2ccc52c6cfdf8f55801c5c4ab0401845a4024a0 100644 --- a/packages/uni-mp-compiler/__tests__/slot.spec.ts +++ b/packages/uni-mp-compiler/__tests__/slot.spec.ts @@ -50,6 +50,15 @@ describe('compiler: transform slot', () => { ``, `(_ctx, _cache) => { return {} +}` + ) + }) + test('slot with component', () => { + assert( + `fallback`, + `fallback`, + `(_ctx, _cache) => { + return {} }` ) }) diff --git a/packages/uni-mp-compiler/src/template/codegen.ts b/packages/uni-mp-compiler/src/template/codegen.ts index 02f216323758fe0826204dc97d184b52848c3c0f..1402231a3864cafbd43f2d27d8bafa44ed5ab1fc 100644 --- a/packages/uni-mp-compiler/src/template/codegen.ts +++ b/packages/uni-mp-compiler/src/template/codegen.ts @@ -13,6 +13,7 @@ import { ElementTypes, ExpressionNode, findProp, + isSlotOutlet, NodeTypes, RootNode, SimpleExpressionNode, @@ -216,7 +217,11 @@ function genTemplate(node: TemplateNode, context: TemplateCodegenContext) { node.children.length === 1 ) { const child = node.children[0] - if (isElementNode(child) && !isForElementNode(child)) { + if ( + isElementNode(child) && + !isForElementNode(child) && + !isSlotOutlet(child) + ) { child.props.push(slotProp) return genElement(child, context) }