babel-plugin-transform-react-inline-elements
Advanced tools
Comparing version 7.0.0-alpha.15 to 7.0.0-alpha.16
@@ -14,2 +14,3 @@ "use strict"; | ||
} | ||
return false; | ||
@@ -19,3 +20,5 @@ } | ||
function isJSXAttributeOfName(attr, name) { | ||
return t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name, { name: name }); | ||
return t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name, { | ||
name: name | ||
}); | ||
} | ||
@@ -25,3 +28,3 @@ | ||
var value = attr.value; | ||
if (!value) return t.identifier("true"); | ||
if (!value) return t.booleanLiteral(true); | ||
if (t.isJSXExpressionContainer(value)) value = value.expression; | ||
@@ -35,6 +38,4 @@ return value; | ||
var node = path.node; | ||
var open = node.openingElement; | ||
if (hasRefOrSpread(open.attributes)) return; | ||
var props = t.objectExpression([]); | ||
@@ -52,16 +53,7 @@ var key = null; | ||
for (var _iterator = open.attributes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref2; | ||
var _arr = open.attributes; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref2 = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref2 = _i.value; | ||
} | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
var attr = _arr[_i]; | ||
var attr = _ref2; | ||
if (isJSXAttributeOfName(attr, "key")) { | ||
@@ -77,2 +69,3 @@ key = getAttributeValue(attr); | ||
var args = [type, props]; | ||
if (key || node.children.length) { | ||
@@ -79,0 +72,0 @@ var children = t.react.buildChildren(node); |
{ | ||
"name": "babel-plugin-transform-react-inline-elements", | ||
"version": "7.0.0-alpha.15", | ||
"version": "7.0.0-alpha.16", | ||
"description": "Turn JSX elements into exploded React objects", | ||
@@ -12,4 +12,4 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-inline-elements", | ||
"devDependencies": { | ||
"babel-helper-plugin-test-runner": "7.0.0-alpha.15" | ||
"babel-helper-plugin-test-runner": "7.0.0-alpha.16" | ||
} | ||
} |
3662
59