Skip to content

Commit

Permalink
fix(transformer/jsx): incorrect isStaticChildren argument for Fragmen…
Browse files Browse the repository at this point in the history
…ts with multiple children
  • Loading branch information
Dunqing committed Jan 25, 2025
1 parent 4a2f2a9 commit df1c995
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
7 changes: 3 additions & 4 deletions crates/oxc_transformer/src/jsx/jsx_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tasks/transform_conformance/snapshots/oxc.snap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
commit: acbc09a8

Passed: 132/154
Passed: 133/155

# All Passed:
* babel-plugin-transform-class-static-block
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<>
<div></div>
<div></div>
</>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"plugins": [["transform-react-jsx-development"]],
"sourceType": "module"
}
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit df1c995

Please sign in to comment.