Add JSX Fragment syntax support (#6552)

* Add JSX Fragments to babel-types

* Support JSX fragments in the transform-react-jsx plugin

* Add tests JSX fragments

* Update helper-builder and transform plugin documentations for jsx fragment

* Add generator for jsx fragments

* Add test for jsx fragment generator

* Split jsx transform example into normal and fragment examples

* Remove unnecessary fields from ElementState in babel-helper-builder-react-jsx

* inline [skip ci]
This commit is contained in:
Clement Hoang
2017-11-03 07:43:48 -07:00
committed by Henry Zhu
parent 9e2828322e
commit 1a7194a22f
20 changed files with 322 additions and 29 deletions

View File

@@ -0,0 +1,12 @@
<div>
< >
<>
<span>Hello</span>
<span>world</span>
</>
<>
<span>Goodbye</span>
<span>world</span>
</>
</>
</div>

View File

@@ -0,0 +1 @@
React.createElement("div", null, React.createElement(React.Fragment, null, React.createElement(React.Fragment, null, React.createElement("span", null, "Hello"), React.createElement("span", null, "world")), React.createElement(React.Fragment, null, React.createElement("span", null, "Goodbye"), React.createElement("span", null, "world"))));

View File

@@ -0,0 +1,3 @@
/** @jsx dom */
<div>no fragment is used</div>

View File

@@ -0,0 +1,2 @@
/** @jsx dom */
dom("div", null, "no fragment is used");

View File

@@ -0,0 +1,4 @@
/** @jsx dom */
/** @jsxFrag DomFrag */
<></>

View File

@@ -0,0 +1,4 @@
/** @jsx dom */
/** @jsxFrag DomFrag */
dom(DomFrag, null);

View File

@@ -0,0 +1,2 @@
/** @jsx dom */
dom(React.Fragment, null);

View File

@@ -0,0 +1,3 @@
{
"throws": "transform-react-jsx: pragma has been set but pragmafrag has not been set"
}