Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler-web): 修复编译slot组件的slot属性失败问题 #219

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@ export default function (node: SlotNode, context: Context) {
}

if (node.attributes.length > 0) {
attributes.push(
t.jsxAttribute(
t.jsxIdentifier('$scopeKeys'),
t.jsxExpressionContainer(
t.arrayExpression(
node.attributes.map((att) =>
t.stringLiteral((att as AttributeNode).name)
// 处理多层组件slot传递问题 <slot slot="xx"></slot>
const scopeArr = node.attributes.filter(f => f.type !== 'NamedSlotAttributeNode')
if (scopeArr.length) {
attributes.push(
t.jsxAttribute(
t.jsxIdentifier('$scopeKeys'),
t.jsxExpressionContainer(
t.arrayExpression(
scopeArr.map((att) =>
t.stringLiteral((att as AttributeNode).name)
)
)
)
)
)
)
}
}

const children = []
Expand Down