提交 bc8110fe 编写于 作者: fxy060608's avatar fxy060608

fix(mp): slot

上级 76d16526
......@@ -50,6 +50,15 @@ describe('compiler: transform slot', () => {
`<button><block wx:if="{{$slots.text}}"><slot name="text"></slot></block><block wx:else>Submit</block></button>`,
`(_ctx, _cache) => {
return {}
}`
)
})
test('slot with component', () => {
assert(
`<view><custom><slot><view>fallback</view></slot></custom></view>`,
`<view><custom u-s="{{['d']}}" u-i="2a9ec0b0-0"><view slot="d"><block wx:if="{{$slots.d}}"><slot name="d"></slot></block><block wx:else><view>fallback</view></block></view></custom></view>`,
`(_ctx, _cache) => {
return {}
}`
)
})
......
......@@ -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)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册