Fix #9 by removing invalid logic introduced with #1.

This commit is contained in:
Ingvar Stepanyan 2014-11-28 16:51:50 +02:00
parent 7a3683de2b
commit 879d40989a
2 changed files with 9 additions and 14 deletions

View File

@ -296,7 +296,7 @@
// `strict` indicates whether strict mode is on. // `strict` indicates whether strict mode is on.
var inFunction, inGenerator, labels, strict, var inFunction, inGenerator, labels, strict,
inXJSChild, inXJSTag, inXJSChildExpression; inXJSChild, inXJSTag;
// This counter is used for checking that arrow expressions did // This counter is used for checking that arrow expressions did
// not contain nested parentheses in argument list. // not contain nested parentheses in argument list.
@ -618,9 +618,7 @@
tokEnd = tokPos; tokEnd = tokPos;
if (options.locations) tokEndLoc = new Position; if (options.locations) tokEndLoc = new Position;
tokType = type; tokType = type;
if (shouldSkipSpace !== false && !(inXJSChild && tokType !== _braceL)) { if (shouldSkipSpace !== false) skipSpace();
skipSpace();
}
tokVal = val; tokVal = val;
tokRegexpAllowed = type.beforeExpr; tokRegexpAllowed = type.beforeExpr;
if (options.onToken) { if (options.onToken) {
@ -846,7 +844,7 @@
case 91: ++tokPos; return finishToken(_bracketL); case 91: ++tokPos; return finishToken(_bracketL);
case 93: ++tokPos; return finishToken(_bracketR); case 93: ++tokPos; return finishToken(_bracketR);
case 123: ++tokPos; return finishToken(_braceL); case 123: ++tokPos; return finishToken(_braceL);
case 125: ++tokPos; return finishToken(_braceR, undefined, !inXJSChildExpression); case 125: ++tokPos; return finishToken(_braceR, undefined, !inXJSChild);
case 58: ++tokPos; return finishToken(_colon); case 58: ++tokPos; return finishToken(_colon);
case 63: ++tokPos; return finishToken(_question); case 63: ++tokPos; return finishToken(_question);
@ -2549,8 +2547,6 @@
function parseObj() { function parseObj() {
var node = startNode(), first = true, propHash = {}; var node = startNode(), first = true, propHash = {};
node.properties = []; node.properties = [];
var origInXJSChildExpression = inXJSChildExpression;
inXJSChildExpression = false;
next(); next();
while (!eat(_braceR)) { while (!eat(_braceR)) {
if (!first) { if (!first) {
@ -2587,7 +2583,6 @@
checkPropClash(prop, propHash); checkPropClash(prop, propHash);
node.properties.push(finishNode(prop, "Property")); node.properties.push(finishNode(prop, "Property"));
} }
inXJSChildExpression = origInXJSChildExpression;
return finishNode(node, "ObjectExpression"); return finishNode(node, "ObjectExpression");
} }
@ -3153,15 +3148,16 @@
inXJSTag = false; inXJSTag = false;
inXJSChild = false; inXJSChild = false;
inXJSChildExpression = origInXJSChild;
next(); next();
node.expression = tokType === _braceR ? parseXJSEmptyExpression() : parseExpression(); node.expression = tokType === _braceR ? parseXJSEmptyExpression() : parseExpression();
inXJSTag = origInXJSTag; inXJSTag = origInXJSTag;
inXJSChild = origInXJSChild; inXJSChild = origInXJSChild;
inXJSChildExpression = false;
if (inXJSChild) {
tokPos = tokEnd;
}
expect(_braceR); expect(_braceR);
return finishNode(node, "XJSExpressionContainer"); return finishNode(node, "XJSExpressionContainer");
} }
@ -3172,14 +3168,13 @@
if (tokType === _braceL) { if (tokType === _braceL) {
var tokStart1 = tokStart, tokStartLoc1 = tokStartLoc; var tokStart1 = tokStart, tokStartLoc1 = tokStartLoc;
var origInXJSTag = inXJSTag, origInXJSChildExpression = inXJSChildExpression; var origInXJSTag = inXJSTag;
inXJSTag = inXJSChildExpression = false; inXJSTag = false;
next(); next();
if (tokType !== _ellipsis) unexpected(); if (tokType !== _ellipsis) unexpected();
var node = parseMaybeUnary(); var node = parseMaybeUnary();
inXJSChildExpression = origInXJSChildExpression;
inXJSTag = origInXJSTag; inXJSTag = origInXJSTag;
expect(_braceR); expect(_braceR);

View File

@ -2,7 +2,7 @@
"name": "acorn-jsx", "name": "acorn-jsx",
"description": "Alternative React JSX parser", "description": "Alternative React JSX parser",
"main": "acorn.js", "main": "acorn.js",
"version": "0.9.1-5", "version": "0.9.1-6",
"maintainers": [ "maintainers": [
{ {
"name": "Marijn Haverbeke", "name": "Marijn Haverbeke",