Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -546,16 +546,14 @@ function createPropsProperties(
let refProperty: ObjectProperty | undefined;
let keyProperty: ObjectProperty | undefined;
const props: Array<ObjectProperty | SpreadPattern> = [];
const jsxAttributesWithoutKeyAndRef = propAttributes.filter(
p => p.kind === 'JsxAttribute' && p.name !== 'key' && p.name !== 'ref',
const jsxAttributesWithoutKey = propAttributes.filter(
p => p.kind === 'JsxAttribute' && p.name !== 'key',
);
const jsxSpreadAttributes = propAttributes.filter(
p => p.kind === 'JsxSpreadAttribute',
);
const spreadPropsOnly =
jsxAttributesWithoutKeyAndRef.length === 0 &&
jsxSpreadAttributes.length === 1;

jsxAttributesWithoutKey.length === 0 && jsxSpreadAttributes.length === 1;
propAttributes.forEach(prop => {
switch (prop.kind) {
case 'JsxAttribute': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ function ConditionalJsx({shouldWrap}) {
return content;
}

function ComponentWithSpreadPropsAndRef({ref, ...other}) {
return <Foo ref={ref} {...other} />;
}

// TODO: Support value blocks
function TernaryJsx({cond}) {
return cond ? <div /> : null;
Expand Down Expand Up @@ -409,6 +413,41 @@ function ConditionalJsx(t0) {
return content;
}

function ComponentWithSpreadPropsAndRef(t0) {
const $ = _c2(6);
let other;
let ref;
if ($[0] !== t0) {
({ ref, ...other } = t0);
$[0] = t0;
$[1] = other;
$[2] = ref;
} else {
other = $[1];
ref = $[2];
}
let t1;
if ($[3] !== other || $[4] !== ref) {
if (DEV) {
t1 = <Foo ref={ref} {...other} />;
} else {
t1 = {
$$typeof: Symbol.for("react.transitional.element"),
type: Foo,
ref: ref,
key: null,
props: { ref: ref, ...other },
};
}
$[3] = other;
$[4] = ref;
$[5] = t1;
} else {
t1 = $[5];
}
return t1;
}

// TODO: Support value blocks
function TernaryJsx(t0) {
const $ = _c2(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ function ConditionalJsx({shouldWrap}) {
return content;
}

function ComponentWithSpreadPropsAndRef({ref, ...other}) {
return <Foo ref={ref} {...other} />;
}

// TODO: Support value blocks
function TernaryJsx({cond}) {
return cond ? <div /> : null;
Expand Down
Loading