move react children coercion to opening element visitor - fixes #1276

This commit is contained in:
Sebastian McKenzie
2015-04-20 05:49:59 +01:00
parent a44831b3fa
commit 7d4ecea8fb
4 changed files with 33 additions and 7 deletions

View File

@@ -57,6 +57,8 @@ export default function (exports, opts) {
exports.JSXOpeningElement = {
exit(node, parent, scope, file) {
parent.children = react.buildChildren(parent);
var tagExpr = node.name;
var args = [];
@@ -144,10 +146,6 @@ export default function (exports, opts) {
};
exports.JSXElement = {
enter(node) {
node.children = react.buildChildren(node);
},
exit(node) {
var callExpr = node.openingElement;

View File

@@ -34,9 +34,8 @@ function cleanJSXElementLiteralChild(child, args) {
var lines = child.value.split(/\r\n|\n|\r/);
var lastNonEmptyLine = 0;
var i;
for (i = 0; i < lines.length; i++) {
for (let i = 0; i < lines.length; i++) {
if (lines[i].match(/[^ \t]/)) {
lastNonEmptyLine = i;
}
@@ -44,7 +43,7 @@ function cleanJSXElementLiteralChild(child, args) {
var str = "";
for (i = 0; i < lines.length; i++) {
for (let i = 0; i < lines.length; i++) {
var line = lines[i];
var isFirstLine = i === 0;