optimisations.react.inline: don't pass empty array.

This fixes incompatibilities with code that check for the existence
of children.
This commit is contained in:
Samuel Reed
2015-10-29 21:18:07 -05:00
parent b9160b3a6c
commit b98d24594a
3 changed files with 16 additions and 2 deletions

View File

@@ -43,8 +43,10 @@ export default function ({ types: t }) {
if (node.children.length) {
let children = t.react.buildChildren(node);
children = children.length === 1 ? children[0] : t.arrayExpression(children);
pushProp(props.properties, t.identifier("children"), children);
if (children.length) {
children = children.length === 1 ? children[0] : t.arrayExpression(children);
pushProp(props.properties, t.identifier("children"), children);
}
}
// props