@samitouri / QOS-React-2 / commits / 280ff2e5a7

Unbreak JSX comment comma fix

Andreas Svensson committed Mar 11, 2014 at 00:31 UTC 280ff2e5a78d2bc32309685749e57e5aa79dfe5d
1 file changed +14 -5
vendor/fbtransform/transforms/react.js
+14 -5
@@ -130,17 +130,26 @@ function visitReactTag(traverse, object, path, state) {
130 var childrenToRender = object.children.filter(function(child) {
131 return !(child.type === Syntax.Literal
132 && typeof child.value === 'string'
133 - && child.value.match(/^[ \t]*[\r\n][ \t\r\n]*$/)
134 - || child.type === Syntax.XJSExpressionContainer
135 - && child.expression.type === Syntax.XJSEmptyExpression);
133 + && child.value.match(/^[ \t]*[\r\n][ \t\r\n]*$/));
134 });
135 if (childrenToRender.length > 0) {
138 - utils.append(', ', state);
136 + var lastRenderableIndex;
137 +
138 + childrenToRender.forEach(function(child, index) {
139 + if (child.type !== Syntax.XJSExpressionContainer ||
140 + child.expression.type !== Syntax.XJSEmptyExpression) {
141 + lastRenderableIndex = index;
142 + }
143 + });
144 +
145 + if (lastRenderableIndex !== undefined) {
146 + utils.append(', ', state);
147 + }
148
149 childrenToRender.forEach(function(child, index) {
150 utils.catchup(child.range[0], state);
151
143 - var isLast = index === childrenToRender.length - 1;
152 + var isLast = index >= lastRenderableIndex;
153
154 if (child.type === Syntax.Literal) {
155 renderXJSLiteral(child, isLast, state);