Optimize jsx spreads of object expressions (#12557)
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<p prop prop>text</p>;
|
||||
|
||||
<p {...{prop, prop}}>text</p>;
|
||||
|
||||
<p prop {...{prop}}>text</p>;
|
||||
|
||||
<p {...{prop}} prop>text</p>;
|
||||
@@ -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"
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
<p {...props}>text</p>;
|
||||
|
||||
<div {...props}>{contents}</div>;
|
||||
|
||||
<img alt="" {...{src, title}} />;
|
||||
|
||||
<blockquote {...{cite}}>{items}</blockquote>;
|
||||
@@ -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
packages/babel-plugin-transform-react-jsx/test/fixtures/react/avoids-spread/input.js
vendored
Normal file
11
packages/babel-plugin-transform-react-jsx/test/fixtures/react/avoids-spread/input.js
vendored
Normal file
@@ -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
packages/babel-plugin-transform-react-jsx/test/fixtures/react/avoids-spread/output.js
vendored
Normal file
32
packages/babel-plugin-transform-react-jsx/test/fixtures/react/avoids-spread/output.js
vendored
Normal file
@@ -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
packages/babel-plugin-transform-react-jsx/test/fixtures/react/duplicate-props/input.js
vendored
Normal file
7
packages/babel-plugin-transform-react-jsx/test/fixtures/react/duplicate-props/input.js
vendored
Normal file
@@ -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
packages/babel-plugin-transform-react-jsx/test/fixtures/react/duplicate-props/output.js
vendored
Normal file
23
packages/babel-plugin-transform-react-jsx/test/fixtures/react/duplicate-props/output.js
vendored
Normal file
@@ -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
packages/babel-plugin-transform-react-jsx/test/fixtures/react/flattens-spread/input.js
vendored
Normal file
7
packages/babel-plugin-transform-react-jsx/test/fixtures/react/flattens-spread/input.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<p {...props}>text</p>;
|
||||
|
||||
<div {...props}>{contents}</div>;
|
||||
|
||||
<img alt="" {...{src, title}} />;
|
||||
|
||||
<blockquote {...{cite}}>{items}</blockquote>;
|
||||
17
packages/babel-plugin-transform-react-jsx/test/fixtures/react/flattens-spread/output.js
vendored
Normal file
17
packages/babel-plugin-transform-react-jsx/test/fixtures/react/flattens-spread/output.js
vendored
Normal file
@@ -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);
|
||||
Reference in New Issue
Block a user