Skip to content

Comma expression (Sequence expression) incorrectly allowed as JSXAttributeValue #8604

Description

@RyanCavanaugh

Bug Report

Current Behavior

Code like <div>{3, 1}</div> is not treated as a parse error, but it should be.

REPL link

Input Code

// No error
<div>{3, 1}</div>;
// No error
<div foo={1, 2} />;

Expected behavior/code

Expected a parse error.

The JSX Spec specifies JSXChildExpression and JSXAttributeValue as being { AssignmentExpression }, but the comma expression is above AssignmentExpression in the grammar

Environment

  • Babel version(s): 6.26.0
  • Node/npm version: N/A (repl)
  • OS: N/A (repl)
  • Monorepo N/A (repl)
  • How you are using Babel: N/A (repl)

Possible Solution

Additional context/Screenshots

https://stackoverflow.com/questions/52139174/comma-operator-in-typescript-jsx-expressions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has PRarea: jsxoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions