Skip to content

Commit abc2d8e

Browse files
committed
fix: add slotFlags for implicit default slots
1 parent 687be8a commit abc2d8e

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Diff for: packages/babel-plugin-jsx/src/transform-vue-jsx.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,11 @@ const transformJSXElement = (
459459
t.identifier('default'),
460460
child,
461461
),
462-
]);
462+
optimize && t.objectProperty(
463+
t.identifier('_'),
464+
t.numericLiteral(slotFlag),
465+
) as any,
466+
].filter(Boolean));
463467
} else if (t.isObjectExpression(child)) {
464468
VNodeChild = t.objectExpression([
465469
...child.properties,
@@ -472,9 +476,13 @@ const transformJSXElement = (
472476
VNodeChild = isComponent ? t.objectExpression([
473477
t.objectProperty(
474478
t.identifier('default'),
475-
t.arrowFunctionExpression([], t.arrayExpression([child])),
479+
t.arrowFunctionExpression([], child),
476480
),
477-
]) : t.arrayExpression([child]);
481+
optimize && t.objectProperty(
482+
t.identifier('_'),
483+
t.numericLiteral(slotFlag),
484+
) as any,
485+
].filter(Boolean)) : t.arrayExpression([child]);
478486
}
479487
}
480488

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ _createVNode(_resolveComponent(\\"A\\"), null, {
158158
exports[`passing object slots via JSX children single expression, function expression: single expression, function expression 1`] = `
159159
"import { createVNode as _createVNode, resolveComponent as _resolveComponent } from \\"vue\\";
160160
_createVNode(_resolveComponent(\\"A\\"), null, {
161-
default: () => \\"foo\\"
161+
default: () => \\"foo\\",
162+
_: 1
162163
});"
163164
`;
164165

0 commit comments

Comments
 (0)