Skip to content
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

Add proposed fragment changes #93

Merged
merged 6 commits into from
Oct 9, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions AST.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ Any JSX element is bounded by tags — either self-closing or both opening a
```js
interface JSXBoundaryElement <: Node {
name: JSXIdentifier | JSXMemberExpression | JSXNamespacedName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type annotation is now incorrect or you need to describe what should be in here since fragments don't have an identifier nor member expression nor namespace name.

If isFragment is true this is always null, if isFragment is false then this is always not-null.

That's an indication that this shouldn't use a flag but its own interface.

isFragment: boolean;
}

interface JSXOpeningElement <: JSXBoundaryElement {
type: "JSXOpeningElement",
attributes: [ JSXAttribute | JSXSpreadAttribute ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is also not describing the constraints since attributes will always be an empty array.

selfClosing: boolean;
selfClosing: boolean; // if this is true, isFragment must be false, and vice-versa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is not fully describing the type constraints. It's just ad-hoc. Declaring a new interface will avoid that problem.

}

interface JSXClosingElement <: JSXBoundaryElement {
Expand Down Expand Up @@ -133,7 +134,8 @@ interface JSXElement <: Expression {
type: "JSXElement",
openingElement: JSXOpeningElement,
children: [ JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement ],
closingElement: JSXClosingElement | null
closingElement: JSXClosingElement | null,
isFragment: boolean;
}
```

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ JSXElement :

JSXSelfClosingElement :

- `<` JSXElementName JSXAttributes<sub>opt</sub> `/` `>`
(isFragment cannot be true if selfClosing)

JSXOpeningElement :

- `<` JSXElementName JSXAttributes<sub>opt</sub> `>`
(no JSXAttributes allowed if isFragment is true)

JSXClosingElement :

Expand Down