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

babel-transform-jsx: handle JSX fragments #85

Merged
merged 5 commits into from
Jun 13, 2019

Conversation

blikblum
Copy link
Contributor

Makes jsx to htm babel transform handle JSX fragments both React.Fragment and short (<></>) syntax.

Basically removes the fragment nodes

@developit
Copy link
Owner

Isn't the default behaviour what folks want here?

// input:
<Fragment>
  <div />
  <div />
</Fragment>

// output:
html`
  <${Fragment>
    <div />
    <div />
  </${Fragment}>
`

@blikblum
Copy link
Contributor Author

Isn't the default behaviour what folks want here?

No. React.Fragment and its short syntax <></> exists to support multiple roots in JSX/React. Since htm supports multiple roots without special markup there's no need for it

@developit
Copy link
Owner

@blikblum seems reasonable. I'll need a bit to properly review.

@developit developit requested review from jviide and developit and removed request for jviide June 4, 2019 16:18
Copy link
Collaborator

@jviide jviide left a comment

Choose a reason for hiding this comment

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

I think the idea is sound 👍 Added a couple of suggestions regarding the structure and formatting, and added a suggestion to use this opportunity to make the plugin more robust overall.

packages/babel-plugin-transform-jsx-to-htm/index.mjs Outdated Show resolved Hide resolved
packages/babel-plugin-transform-jsx-to-htm/index.mjs Outdated Show resolved Hide resolved
packages/babel-plugin-transform-jsx-to-htm/index.mjs Outdated Show resolved Hide resolved
@jviide jviide self-requested a review June 6, 2019 00:12
Copy link
Collaborator

@jviide jviide left a comment

Choose a reason for hiding this comment

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

Looks good. Great job, @blikblum 👍

@jviide jviide merged commit c5764b5 into developit:master Jun 13, 2019
@jviide
Copy link
Collaborator

jviide commented Jun 13, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants