mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Sync latest JSX transform - all children passed as separate arguments
This was a part of e1fe13d0cb upstream.
This commit is contained in:
Vendored
+7
-1
@@ -91,7 +91,13 @@ function walker(traverse, object, path, state) {
|
||||
}
|
||||
|
||||
function runPass(source, visitors, options) {
|
||||
var ast = esprima.parse(source, { comment: true, loc: true, range: true });
|
||||
var ast;
|
||||
try {
|
||||
ast = esprima.parse(source, { comment: true, loc: true, range: true });
|
||||
} catch (e) {
|
||||
e.message = 'Parse Error: ' + e.message;
|
||||
throw e;
|
||||
}
|
||||
var state = createState(source, options);
|
||||
state.g.originalProgramAST = ast;
|
||||
state.g.visitors = visitors;
|
||||
|
||||
Vendored
+6
-1
@@ -54,7 +54,12 @@ function runCli(argv) {
|
||||
source += chunk;
|
||||
});
|
||||
process.stdin.on('end', function () {
|
||||
source = transformAll(source, options, excludes);
|
||||
try {
|
||||
source = transformAll(source, options, excludes);
|
||||
} catch (e) {
|
||||
console.error(e.stack);
|
||||
process.exit(1);
|
||||
}
|
||||
process.stdout.write(source.code);
|
||||
});
|
||||
}
|
||||
|
||||
+2
-13
@@ -136,14 +136,10 @@ function visitReactTag(traverse, object, path, state) {
|
||||
move(object.openingElement.range[1], state);
|
||||
}
|
||||
|
||||
// separate props and children arguments
|
||||
append(', ', state);
|
||||
|
||||
// filter out whitespace
|
||||
if (childrenToRender.length > 0) {
|
||||
if (childrenToRender.length > 1) {
|
||||
append('[', state);
|
||||
}
|
||||
append(', ', state);
|
||||
|
||||
object.children.forEach(function(child) {
|
||||
if (child.type === Syntax.Literal && !child.value.match(/\S/)) {
|
||||
return;
|
||||
@@ -166,8 +162,6 @@ function visitReactTag(traverse, object, path, state) {
|
||||
|
||||
catchup(child.range[1], state);
|
||||
});
|
||||
} else {
|
||||
append('null', state);
|
||||
}
|
||||
|
||||
if (object.selfClosing) {
|
||||
@@ -180,11 +174,6 @@ function visitReactTag(traverse, object, path, state) {
|
||||
move(object.closingElement.range[1], state);
|
||||
}
|
||||
|
||||
if (childrenToRender.length > 0) {
|
||||
if (childrenToRender.length > 1) {
|
||||
append(']', state);
|
||||
}
|
||||
}
|
||||
append(')', state);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user