fix: add slotFlags for implicit default slots

This commit is contained in:
Kael 2023-03-30 03:16:08 +11:00
parent 687be8aca8
commit abc2d8ed9c
2 changed files with 13 additions and 4 deletions

View File

@ -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,
@ -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]);
}
}

View File

@ -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
});"
`;