diff --git a/acorn.js b/acorn.js index ce23f3c453..fbcefa5c43 100644 --- a/acorn.js +++ b/acorn.js @@ -2607,6 +2607,8 @@ function parseObj() { var node = startNode(), first = true, propHash = {}; node.properties = []; + var origInXJSChildExpression = inXJSChildExpression; + inXJSChildExpression = false; next(); while (!eat(_braceR)) { if (!first) { @@ -2646,9 +2648,10 @@ checkPropClash(prop, propHash); node.properties.push(finishNode(prop, "Property")); - } + } + inXJSChildExpression = origInXJSChildExpression; return finishNode(node, "ObjectExpression"); - } + } function parsePropertyName(prop) { if (options.ecmaVersion >= 6) { @@ -3245,7 +3248,7 @@ inXJSTag = origInXJSTag; inXJSChild = origInXJSChild; inXJSChildExpression = false; - + expect(_braceR); return finishNode(node, "XJSExpressionContainer"); } diff --git a/package.json b/package.json index 82e35a281b..14d8eb67ec 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "acorn-6to5", "description": "Acorn fork used by 6to5", "main": "acorn.js", - "version": "0.9.1-3", + "version": "0.9.1-4", "maintainers": [ { "name": "Marijn Haverbeke", diff --git a/test/tests-jsx.js b/test/tests-jsx.js index d0348a253e..a07f0aea2e 100644 --- a/test/tests-jsx.js +++ b/test/tests-jsx.js @@ -3306,80 +3306,141 @@ var fbTestFixture = { }, '
{
}
': { - type: 'Program', + type: 'ExpressionStatement', start: 0, end: 30, - body: [{ - type: 'ExpressionStatement', + expression: { + type: 'XJSElement', start: 0, end: 30, - expression: { - type: 'XJSElement', + openingElement: { + type: 'XJSOpeningElement', start: 0, + end: 5, + attributes: [], + name: { + type: 'XJSIdentifier', + start: 1, + end: 4, + name: 'div' + }, + selfClosing: false + }, + closingElement: { + type: 'XJSClosingElement', + start: 24, end: 30, - openingElement: { - type: 'XJSOpeningElement', - start: 0, - end: 5, - attributes: [], - name: { - type: 'XJSIdentifier', - start: 1, - end: 4, - name: 'div' - }, - selfClosing: false - }, - closingElement: { - type: 'XJSClosingElement', - start: 24, - end: 30, - name: { - type: 'XJSIdentifier', - start: 26, - end: 29, - name: 'div' - } - }, - children: [{ - type: 'XJSExpressionContainer', - start: 5, - end: 24, - expression: { - type: 'XJSElement', + name: { + type: 'XJSIdentifier', + start: 26, + end: 29, + name: 'div' + } + }, + children: [{ + type: 'XJSExpressionContainer', + start: 5, + end: 24, + expression: { + type: 'XJSElement', + start: 6, + end: 23, + openingElement: { + type: 'XJSOpeningElement', start: 6, end: 23, - openingElement: { - type: 'XJSOpeningElement', - start: 6, - end: 23, - attributes: [ - { - type: 'XJSSpreadAttribute', - start: 11, - end: 20, - argument: { - type: 'Identifier', - start: 15, - end: 19, - name: 'test' - } + attributes: [ + { + type: 'XJSSpreadAttribute', + start: 11, + end: 20, + argument: { + type: 'Identifier', + start: 15, + end: 19, + name: 'test' } - ], - name: { - type: 'XJSIdentifier', - start: 7, - end: 10, - name: 'div' - }, - selfClosing: true + } + ], + name: { + type: 'XJSIdentifier', + start: 7, + end: 10, + name: 'div' }, - closingElement: null, - children: [] - } - }] - } - }] + selfClosing: true + }, + closingElement: null, + children: [] + } + }] + } + }, + + '
{ {a} }
': { + type: "ExpressionStatement", + start: 0, + end: 18, + expression: { + type: "XJSElement", + start: 0, + end: 18, + openingElement: { + type: "XJSOpeningElement", + start: 0, + end: 5, + attributes: [], + name: { + type: "XJSIdentifier", + start: 1, + end: 4, + name: "div" + }, + selfClosing: false + }, + closingElement: { + type: "XJSClosingElement", + start: 12, + end: 18, + name: { + type: "XJSIdentifier", + start: 14, + end: 17, + name: "div" + } + }, + children: [{ + type: "XJSExpressionContainer", + start: 5, + end: 12, + expression: { + type: "ObjectExpression", + start: 7, + end: 10, + properties: [{ + type: "Property", + start: 8, + end: 9, + method: false, + shorthand: true, + computed: false, + key: { + type: "Identifier", + start: 8, + end: 9, + name: "a" + }, + kind: "init", + value: { + type: "Identifier", + start: 8, + end: 9, + name: "a" + } + }] + } + }] + } } } };