fix(transformer/jsx): incorrect isStaticChildren argument for Fragment with multiple children (#8713)

close: #8650
This commit is contained in:
Dunqing 2025-01-25 16:11:28 +00:00
parent bf8be23f11
commit e7ab96cbb6
5 changed files with 24 additions and 6 deletions

View file

@ -719,10 +719,9 @@ impl<'a> JsxImpl<'a, '_> {
// isStaticChildren
if is_development {
arguments.push(Argument::from(ctx.ast.expression_boolean_literal(
SPAN,
if is_fragment { false } else { children_len > 1 },
)));
arguments.push(Argument::from(
ctx.ast.expression_boolean_literal(SPAN, children_len > 1),
));
}
// Fragment doesn't have source and self

View file

@ -1,6 +1,6 @@
commit: acbc09a8
Passed: 132/154
Passed: 133/155
# All Passed:
* babel-plugin-transform-class-static-block
@ -261,7 +261,7 @@ rebuilt : SymbolId(2): []
x Output mismatch
# babel-plugin-transform-react-jsx (34/37)
# babel-plugin-transform-react-jsx (35/38)
* refresh/does-not-transform-it-because-it-is-not-used-in-the-AST/input.jsx
x Output mismatch

View file

@ -0,0 +1,4 @@
<>
<div></div>
<div></div>
</>

View file

@ -0,0 +1,4 @@
{
"plugins": [["transform-react-jsx-development"]],
"sourceType": "module"
}

View file

@ -0,0 +1,11 @@
var _jsxFileName = "<CWD>/tests/babel-plugin-transform-react-jsx/test/fixtures/fragment-static-children/input.jsx";
import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "react/jsx-dev-runtime";
_jsxDEV(_Fragment, { children: [_jsxDEV("div", {}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 2,
columnNumber: 3
}, this), _jsxDEV("div", {}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 3,
columnNumber: 3
}, this)] }, void 0, true);