Skip to content

Commit

Permalink
Add proposed fragment changes (#93)
Browse files Browse the repository at this point in the history
* Add proposed fragment changes

* Use explicit JSXFragment node instead of flags in JSXElement

* Remove JSXOpeningFragment and JSXClosingFragment from authoritative spec

* Make fragment syntax tokens more explicit

* Make wording less awkward
  • Loading branch information
clemmy authored and sebmarkbage committed Oct 9, 2017
1 parent d7efe5c commit 2c657b8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
30 changes: 28 additions & 2 deletions AST.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,43 @@ interface JSXText <: Node {
JSX Element
-----------

Finally, JSX element itself consists of opening element, list of children and optional closing element:
JSX element consists of opening element, list of children and optional closing element:

```js
interface JSXElement <: Expression {
type: "JSXElement";
openingElement: JSXOpeningElement;
children: [ JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement ];
children: [ JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment ];
closingElement: JSXClosingElement | null;
}
```

JSX Fragment
------------

JSX fragment consists of an opening fragment, list of children, and closing fragment:

```js
interface JSXFragment <: Expression {
type: "JSXFragment";
openingFragment: JSXOpeningFragment;
children: [ JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment ];
closingFragment: JSXClosingFragment;
}
```

```js
interface JSXOpeningFragment <: Node {
type: "JSXOpeningFragment";
}
```

```js
interface JSXClosingFragment <: Node {
type: "JSXClosingFragment";
}
```

Tools that work with JSX AST
----------------------------

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ _JSX extends the PrimaryExpression in the [ECMAScript 6th Edition (ECMA-262)](ht
PrimaryExpression :

- JSXElement
- JSXFragment

__Elements__

Expand All @@ -60,6 +61,10 @@ JSXClosingElement :

- `<` `/` JSXElementName `>`

JSXFragment :

- `<` `>` JSXChildren<sub>opt</sub> `<` `/` `>`

JSXElementName :

- JSXIdentifier
Expand Down

0 comments on commit 2c657b8

Please sign in to comment.