Skip to content

Commit 453d99f

Browse files
committed
fix: add slotFlags for implicit default slots
1 parent 5e77d5d commit 453d99f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

packages/babel-plugin-jsx/src/transform-vue-jsx.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,11 @@ const transformJSXElement = (
512512
) {
513513
VNodeChild = t.objectExpression([
514514
t.objectProperty(t.identifier('default'), child),
515-
]);
515+
optimize && t.objectProperty(
516+
t.identifier('_'),
517+
t.numericLiteral(slotFlag),
518+
) as any,
519+
].filter(Boolean));
516520
} else if (t.isObjectExpression(child)) {
517521
VNodeChild = t.objectExpression(
518522
[
@@ -526,9 +530,13 @@ const transformJSXElement = (
526530
? t.objectExpression([
527531
t.objectProperty(
528532
t.identifier('default'),
529-
t.arrowFunctionExpression([], t.arrayExpression([child]))
533+
t.arrowFunctionExpression([], child),
530534
),
531-
])
535+
optimize && t.objectProperty(
536+
t.identifier('_'),
537+
t.numericLiteral(slotFlag),
538+
) as any,
539+
].filter(Boolean))
532540
: t.arrayExpression([child]);
533541
}
534542
}

packages/babel-plugin-jsx/test/__snapshots__/snapshot.test.ts.snap

+2-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ _createVNode(_resolveComponent("A"), null, {
164164
exports[`passing object slots via JSX children single expression, function expression > single expression, function expression 1`] = `
165165
"import { resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
166166
_createVNode(_resolveComponent("A"), null, {
167-
default: () => "foo"
167+
default: () => "foo",
168+
_: 1
168169
});"
169170
`;
170171

0 commit comments

Comments
 (0)