diff --git a/src/babel/transformation/transformers/optimisation/react.inline-elements.js b/src/babel/transformation/transformers/optimisation/react.inline-elements.js index 1e06ac833f..5c336788a2 100644 --- a/src/babel/transformation/transformers/optimisation/react.inline-elements.js +++ b/src/babel/transformation/transformers/optimisation/react.inline-elements.js @@ -57,7 +57,7 @@ export function JSXElement(node, parent, scope, file) { if (isJSXAttributeOfName(attr, "key")) { key = attr.value; } else { - pushProp(props.properties, attr.name, attr.value); + pushProp(props.properties, attr.name, attr.value || t.identifier("true")); } } diff --git a/test/core/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/actual.js b/test/core/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/actual.js new file mode 100644 index 0000000000..0545343f92 --- /dev/null +++ b/test/core/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/actual.js @@ -0,0 +1 @@ +; diff --git a/test/core/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/expected.js b/test/core/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/expected.js new file mode 100644 index 0000000000..452322c2de --- /dev/null +++ b/test/core/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/expected.js @@ -0,0 +1,10 @@ +"use strict"; + +({ + type: Foo, + ref: null, + props: babelHelpers.defaultProps(Foo.defaultProps, { + bar: true + }), + key: null +});