-
Notifications
You must be signed in to change notification settings - Fork 130
Disallow < after a JSX element
#141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,17 +52,41 @@ render(dropdown); | |
|
|
||
| <h2>Syntax</h2> | ||
| <emu-grammar> | ||
| PrimaryExpression : | ||
| <ins>JSXElement</ins> | ||
| <ins>JSXFragment</ins> | ||
| PrimaryExpression :: | ||
| <ins>JSXElementOrFragment `<`</ins> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this production to be able to define an early error on
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could do something like but I used that new production to avoid introducing new language/checks that are not already used in the ecma262 spec
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand that without
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that the ecma262 spec already does this in a few cases, for example to disallow |
||
| <ins>JSXElementOrFragment</ins> | ||
| </emu-grammar> | ||
|
|
||
| <emu-clause type="sdo" id="sec-jsx-PrimaryExpression-early-errors"> | ||
| <h1>Static Semantics: Early Errors</h1> | ||
| <emu-grammar> | ||
| PrimaryExpression :: JSXElementOrFragment `<` | ||
| </emu-grammar> | ||
| <ul> | ||
| <li>It is a SyntaxError if any source text is matched by this production.</li> | ||
| </ul> | ||
| <emu-note> | ||
| This Early Error prevents users from accidentally writing two adjacent JSX elements without wrapping them in a fragment: | ||
| <pre><code class="language-jsx"> | ||
| // Invalid | ||
| var elts = <a></a><b></b> | ||
|
|
||
| // Valid | ||
| var elts = <><a></a><b></b></> | ||
| </code></pre> | ||
| </emu-note> | ||
| </emu-clause> | ||
| </emu-clause> | ||
|
|
||
| <emu-clause id="sec-jsx-elements"> | ||
| <h1>JSX Elements</h1> | ||
| <h2>Syntax</h2> | ||
|
|
||
| <emu-grammar type="definition"> | ||
| JSXElementOrFragment :: | ||
| JSXElement | ||
| JSXFragment | ||
|
|
||
| JSXElement : | ||
| JSXSelfClosingElement | ||
| JSXOpeningElement JSXChildren? JSXClosingElement | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.