Skip to content

Commit

Permalink
fix: add slotFlags for implicit default slots
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Mar 29, 2023
1 parent 687be8a commit abc2d8e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 11 additions & 3 deletions packages/babel-plugin-jsx/src/transform-vue-jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,11 @@ const transformJSXElement = (
t.identifier('default'),
child,
),
]);
optimize && t.objectProperty(
t.identifier('_'),
t.numericLiteral(slotFlag),
) as any,
].filter(Boolean));
} else if (t.isObjectExpression(child)) {
VNodeChild = t.objectExpression([
...child.properties,
Expand All @@ -472,9 +476,13 @@ const transformJSXElement = (
VNodeChild = isComponent ? t.objectExpression([
t.objectProperty(
t.identifier('default'),
t.arrowFunctionExpression([], t.arrayExpression([child])),
t.arrowFunctionExpression([], child),
),
]) : t.arrayExpression([child]);
optimize && t.objectProperty(
t.identifier('_'),
t.numericLiteral(slotFlag),
) as any,
].filter(Boolean)) : t.arrayExpression([child]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ _createVNode(_resolveComponent(\\"A\\"), null, {
exports[`passing object slots via JSX children single expression, function expression: single expression, function expression 1`] = `
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from \\"vue\\";
_createVNode(_resolveComponent(\\"A\\"), null, {
default: () => \\"foo\\"
default: () => \\"foo\\",
_: 1
});"
`;

Expand Down

0 comments on commit abc2d8e

Please sign in to comment.