Skip to content

Commit 8deba78

Browse files
authored
fix(es/parser): Disallow spread operator(...) in JSX attribute values (#10587)
**Related issue:** - Closes #10586
1 parent e1f2597 commit 8deba78

File tree

10 files changed

+24
-15
lines changed

10 files changed

+24
-15
lines changed

.changeset/tiny-melons-carry.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
swc_ecma_lexer: patch
3+
swc_core: patch
4+
---
5+
6+
fix(es/parser): disallow spread operator in JSX attribute values

crates/swc_ecma_lexer/src/common/parser/jsx.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ fn parse_jsx_expr_container<'a, P: Parser<'a>>(p: &mut P, _: BytePos) -> PResult
5050
let expr = if p.input_mut().is(&P::Token::RBRACE) {
5151
JSXExpr::JSXEmptyExpr(parse_jsx_empty_expr(p))
5252
} else {
53-
p.input_mut().eat(&P::Token::DOTDOTDOT);
5453
p.parse_expr().map(JSXExpr::Expr)?
5554
};
5655
expect!(p, &P::Token::RBRACE);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<n c={...b}></n>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
x Expression expected
2+
,-[$DIR/tests/jsx/errors/issue-10586/input.js:1:1]
3+
1 | <n c={...b}></n>
4+
: ^^^
5+
`----
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
x Expression expected
2+
,-[$DIR/tests/jsx/errors/issue-6977/1/input.js:4:1]
3+
3 |
4+
4 | <Component x={...[1,2,3]} />
5+
: ^^^
6+
`----
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
x Expression expected
2+
,-[$DIR/tests/jsx/errors/issue-6977/2/input.js:4:1]
3+
3 |
4+
4 | <Component x={...{a: x}} />
5+
: ^^^
6+
`----

crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/1/output.mjs

Lines changed: 0 additions & 8 deletions
This file was deleted.

crates/swc_ecma_transforms_react/tests/jsx/fixture/issue-6977/2/output.mjs

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)