Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize jsx spreads of object expressions (#12557)
- Loading branch information
Showing
11 changed files
with
197 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...s/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/duplicate-props/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p prop prop>text</p>; | ||
|
||
<p {...{prop, prop}}>text</p>; | ||
|
||
<p prop {...{prop}}>text</p>; | ||
|
||
<p {...{prop}} prop>text</p>; |
29 changes: 29 additions & 0 deletions
29
...babel-plugin-transform-react-jsx/test/fixtures/react-automatic/duplicate-props/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
|
||
/*#__PURE__*/ | ||
_jsx("p", { | ||
prop: true, | ||
prop: true, | ||
children: "text" | ||
}); | ||
|
||
/*#__PURE__*/ | ||
_jsx("p", { | ||
prop, | ||
prop, | ||
children: "text" | ||
}); | ||
|
||
/*#__PURE__*/ | ||
_jsx("p", { | ||
prop: true, | ||
prop, | ||
children: "text" | ||
}); | ||
|
||
/*#__PURE__*/ | ||
_jsx("p", { | ||
prop, | ||
prop: true, | ||
children: "text" | ||
}); |
7 changes: 7 additions & 0 deletions
7
...s/babel-plugin-transform-react-jsx/test/fixtures/react-automatic/flattens-spread/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p {...props}>text</p>; | ||
|
||
<div {...props}>{contents}</div>; | ||
|
||
<img alt="" {...{src, title}} />; | ||
|
||
<blockquote {...{cite}}>{items}</blockquote>; |
24 changes: 24 additions & 0 deletions
24
...babel-plugin-transform-react-jsx/test/fixtures/react-automatic/flattens-spread/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { jsx as _jsx } from "react/jsx-runtime"; | ||
|
||
/*#__PURE__*/ | ||
_jsx("p", { ...props, | ||
children: "text" | ||
}); | ||
|
||
/*#__PURE__*/ | ||
_jsx("div", { ...props, | ||
children: contents | ||
}); | ||
|
||
/*#__PURE__*/ | ||
_jsx("img", { | ||
alt: "", | ||
src, | ||
title | ||
}); | ||
|
||
/*#__PURE__*/ | ||
_jsx("blockquote", { | ||
cite, | ||
children: items | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/babel-plugin-transform-react-jsx/test/fixtures/react/avoids-spread/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<E {...props} last />; | ||
|
||
<E first {...props} />; | ||
|
||
<E {...pre} {...suf} />; | ||
|
||
<E first {...pre} mid {...suf} />; | ||
|
||
<E {...pre} mid {...suf} last />; | ||
|
||
<E {...pre} mid1 mid2 {...suf} />; |
32 changes: 32 additions & 0 deletions
32
packages/babel-plugin-transform-react-jsx/test/fixtures/react/avoids-spread/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*#__PURE__*/ | ||
React.createElement(E, babelHelpers.extends({}, props, { | ||
last: true | ||
})); | ||
|
||
/*#__PURE__*/ | ||
React.createElement(E, babelHelpers.extends({ | ||
first: true | ||
}, props)); | ||
|
||
/*#__PURE__*/ | ||
React.createElement(E, babelHelpers.extends({}, pre, suf)); | ||
|
||
/*#__PURE__*/ | ||
React.createElement(E, babelHelpers.extends({ | ||
first: true | ||
}, pre, { | ||
mid: true | ||
}, suf)); | ||
|
||
/*#__PURE__*/ | ||
React.createElement(E, babelHelpers.extends({}, pre, { | ||
mid: true | ||
}, suf, { | ||
last: true | ||
})); | ||
|
||
/*#__PURE__*/ | ||
React.createElement(E, babelHelpers.extends({}, pre, { | ||
mid1: true, | ||
mid2: true | ||
}, suf)); |
7 changes: 7 additions & 0 deletions
7
packages/babel-plugin-transform-react-jsx/test/fixtures/react/duplicate-props/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p prop prop>text</p>; | ||
|
||
<p {...{prop, prop}}>text</p>; | ||
|
||
<p prop {...{prop}}>text</p>; | ||
|
||
<p {...{prop}} prop>text</p>; |
23 changes: 23 additions & 0 deletions
23
packages/babel-plugin-transform-react-jsx/test/fixtures/react/duplicate-props/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/*#__PURE__*/ | ||
React.createElement("p", { | ||
prop: true, | ||
prop: true | ||
}, "text"); | ||
|
||
/*#__PURE__*/ | ||
React.createElement("p", { | ||
prop, | ||
prop | ||
}, "text"); | ||
|
||
/*#__PURE__*/ | ||
React.createElement("p", { | ||
prop: true, | ||
prop | ||
}, "text"); | ||
|
||
/*#__PURE__*/ | ||
React.createElement("p", { | ||
prop, | ||
prop: true | ||
}, "text"); |
7 changes: 7 additions & 0 deletions
7
packages/babel-plugin-transform-react-jsx/test/fixtures/react/flattens-spread/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p {...props}>text</p>; | ||
|
||
<div {...props}>{contents}</div>; | ||
|
||
<img alt="" {...{src, title}} />; | ||
|
||
<blockquote {...{cite}}>{items}</blockquote>; |
17 changes: 17 additions & 0 deletions
17
packages/babel-plugin-transform-react-jsx/test/fixtures/react/flattens-spread/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/*#__PURE__*/ | ||
React.createElement("p", props, "text"); | ||
|
||
/*#__PURE__*/ | ||
React.createElement("div", props, contents); | ||
|
||
/*#__PURE__*/ | ||
React.createElement("img", { | ||
alt: "", | ||
src, | ||
title | ||
}); | ||
|
||
/*#__PURE__*/ | ||
React.createElement("blockquote", { | ||
cite | ||
}, items); |