mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2025-01-10 08:19:10 +08:00
fix: using v-slots without children should not be spread
This commit is contained in:
parent
1f0fcf1049
commit
14adaa5f3a
@ -90,21 +90,25 @@ const transformJSXElement = (
|
||||
---> {{ default: () => [a, b], ...slots }}
|
||||
---> {[a, b]}
|
||||
*/
|
||||
VNodeChild = isComponent ? t.objectExpression([
|
||||
!!children.length && t.objectProperty(
|
||||
t.identifier('default'),
|
||||
t.arrowFunctionExpression([], t.arrayExpression(buildIIFE(path, children))),
|
||||
),
|
||||
...(slots ? (
|
||||
t.isObjectExpression(slots)
|
||||
? (slots! as t.ObjectExpression).properties
|
||||
: [t.spreadElement(slots!)]
|
||||
) : []),
|
||||
optimize && t.objectProperty(
|
||||
t.identifier('_'),
|
||||
t.numericLiteral(slotFlag),
|
||||
),
|
||||
].filter(Boolean as any)) : t.arrayExpression(children);
|
||||
VNodeChild = isComponent
|
||||
? children.length
|
||||
? t.objectExpression([
|
||||
!!children.length && t.objectProperty(
|
||||
t.identifier('default'),
|
||||
t.arrowFunctionExpression([], t.arrayExpression(buildIIFE(path, children))),
|
||||
),
|
||||
...(slots ? (
|
||||
t.isObjectExpression(slots)
|
||||
? (slots! as t.ObjectExpression).properties
|
||||
: [t.spreadElement(slots!)]
|
||||
) : []),
|
||||
optimize && t.objectProperty(
|
||||
t.identifier('_'),
|
||||
t.numericLiteral(slotFlag),
|
||||
),
|
||||
].filter(Boolean as any))
|
||||
: slots
|
||||
: t.arrayExpression(children);
|
||||
} else if (children.length === 1) {
|
||||
/*
|
||||
<A>{a}</A> or <A>{() => a}</A>
|
||||
|
@ -262,6 +262,12 @@ _createVNode(_resolveComponent(\\"C\\"), {
|
||||
}, null, 8, [\\"model\\", \\"onUpdate:model\\"]);"
|
||||
`;
|
||||
|
||||
exports[`using v-slots without children should not be spread: using v-slots without children should not be spread 1`] = `
|
||||
"import { createVNode as _createVNode, resolveDirective as _resolveDirective, resolveComponent as _resolveComponent } from \\"vue\\";
|
||||
|
||||
_createVNode(_resolveComponent(\\"A\\"), null, slots);"
|
||||
`;
|
||||
|
||||
exports[`v-model target value support variable: v-model target value support variable 1`] = `
|
||||
"import { createVNode as _createVNode, resolveComponent as _resolveComponent, Fragment as _Fragment } from \\"vue\\";
|
||||
const foo = 'foo';
|
||||
|
@ -23,7 +23,7 @@ const transpile = (
|
||||
},
|
||||
));
|
||||
|
||||
const tests: Test[] = [
|
||||
[
|
||||
{
|
||||
name: 'input[type="checkbox"]',
|
||||
from: '<input type="checkbox" v-model={test} />',
|
||||
@ -188,9 +188,11 @@ const tests: Test[] = [
|
||||
</>
|
||||
`,
|
||||
},
|
||||
];
|
||||
|
||||
tests.forEach((
|
||||
{
|
||||
name: 'using v-slots without children should not be spread',
|
||||
from: '<A v-slots={slots} />',
|
||||
},
|
||||
].forEach((
|
||||
{ name, from },
|
||||
) => {
|
||||
test(
|
||||
|
Loading…
Reference in New Issue
Block a user