Skip to content

Commit

Permalink
More tests for JSX prop spread expanding
Browse files Browse the repository at this point in the history
Duplicated keys may be created as per current behaviour, using
`@babel/plugin-transform-duplicate-keys` would allow use when
transpiling to strict.
  • Loading branch information
bz2 committed Dec 23, 2020
1 parent 49518aa commit d8afcec
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 0 deletions.
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>;
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"
});
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} />;
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));
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>;
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");

0 comments on commit d8afcec

Please sign in to comment.