From 6a883d2f03d9536e6078f473ae3e54e6160026b2 Mon Sep 17 00:00:00 2001 From: Kael Date: Thu, 30 Mar 2023 03:16:08 +1100 Subject: [PATCH] fix: add slotFlags for implicit default slots --- packages/babel-plugin-jsx/src/transform-vue-jsx.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/babel-plugin-jsx/src/transform-vue-jsx.ts b/packages/babel-plugin-jsx/src/transform-vue-jsx.ts index 6b02ac94..adf0661b 100644 --- a/packages/babel-plugin-jsx/src/transform-vue-jsx.ts +++ b/packages/babel-plugin-jsx/src/transform-vue-jsx.ts @@ -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]); } }