-
Notifications
You must be signed in to change notification settings - Fork 428
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
<JSX> ☲ "Simplified" version of Sander's diff. #775
Conversation
Summary: This is a version of Sander's JSX implementation which treats JSX as "simple" constructs, meaning they are "clearly one unit", and do not require parenthesis to be wrapped around them in order to be passed as function arguments. That means you can treat <tag ...> as the "opening paren" and "</tag>" as the closing paren. This diff also supports: - Frags (which are simply lists that don't require commas separating contents). - Lists of JSX items ``` let myFunction = callSomeFunction <FirstItem>foo</FirstItem> <SecondItem>foo</SecondItem>; let lst = [<Tag />, <AnotherTag />]; let lst = <> <Tag /> <AnotherTag /> </>; ``` Whats Not Implemented: Currently, the limitation of this approach is that subsequent JSX elements must always have spaces separating them. I have a good idea about how to solve that limitation, but we can start using this right now, in an experimental mode. ``` let items = <Wrapper> <This /> <Must /> <Have /> <Spaces /> </Wrapper> ``` Test Plan:Test cases. Reviewers: CC: @vjeux
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @jordwalke @SanderSpies
|
||
let lowerCase = <div argument1=1 />; | ||
|
||
let a = <Foo a>5 </Foo>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the string 5, or seen as {5}
? (maybe this doesn't matter here actually...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the number 5
. We may want to change how children are represented, or at least printed. Right now, the current JavaScript JSX conventions are a special case of what's supported. In Reason
, the expression {5}
is the same as 5
(verify for yourself - it's just a sequence expression with one item returned). So we could print it as <Foo>{5}</Foo>
|
||
let a = <Foo a>5 </Foo>; | ||
|
||
let a = <Foo a>0.55 </Foo>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Foo a>
two spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that seems to be a mistake. Will fix.
the issue alltogether. | ||
|
||
first token | ||
/ \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be aligned with <ident
and args />
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
@bsansouci Want to start adapting this to Cheng Lou's needs? |
I'll commit this, and then if anyone has issues with it, I'll gladly fix them or revert it. Ben needs this in to rebase his changes off of. |
* [JSX] JSX: "Simplified" version of Sander's diff. Summary: This is a version of Sander's JSX implementation which treats JSX as "simple" constructs, meaning they are "clearly one unit", and do not require parenthesis to be wrapped around them in order to be passed as function arguments. That means you can treat <tag ...> as the "opening paren" and "</tag>" as the closing paren. This diff also supports: - Frags (which are simply lists that don't require commas separating contents). - Lists of JSX items ``` let myFunction = callSomeFunction <FirstItem>foo</FirstItem> <SecondItem>foo</SecondItem>; let lst = [<Tag />, <AnotherTag />]; let lst = <> <Tag /> <AnotherTag /> </>; ``` Whats Not Implemented: Currently, the limitation of this approach is that subsequent JSX elements must always have spaces separating them. I have a good idea about how to solve that limitation, but we can start using this right now, in an experimental mode. ``` let items = <Wrapper> <This /> <Must /> <Have /> <Spaces /> </Wrapper> ``` Test Plan:Test cases. Reviewers: CC: @vjeux * More fixes
Summary: This is a version of Sander's JSX Pull Request, but rebased on top of our recent large refactors, and modified to treat
JSX as "simple" constructs, meaning they are "clearly one unit", and do
not require parenthesis to be wrapped around them in order to be passed
as function arguments. That means you can treat <tag ...> as the
"opening paren" and "" as the closing paren.
This diff also supports:
contents).
Whats Not Implemented: Currently, the limitation of this approach is
that subsequent JSX elements must always have spaces separating them.
I have a good idea about how to solve that limitation, but we can start
using this right now, in an experimental mode.
Test Plan:Test cases.
Reviewers: