acornjs / acorn-jsx

Alternative, faster React.js JSX parser
MIT License
648 stars 74 forks source link

Sibling expression container issue #15

Closed wadahiro closed 9 years ago

wadahiro commented 9 years ago

I think it doesn't support sibling expression container like <div>{a}{b}</div> after rewrite. I added following test case to test/tests-jsx.js. 'Unexpected token' error has occurred.

    '<div>{a}{b}</div>': {
      type: "ExpressionStatement",
      start: 0,
      end: 17,
      expression: {
        type: "JSXElement",
        start: 0,
        end: 17,
        openingElement: {
          type: "JSXOpeningElement",
          start: 0,
          end: 5,
          attributes: [],
          name: {
            type: "JSXIdentifier",
            start: 1,
            end: 4,
            name: "div"
          },
          selfClosing: false
        },
        closingElement: {
          type: "JSXClosingElement",
          start: 11,
          end: 17,
          name: {
            type: "JSXIdentifier",
            start: 13,
            end: 16,
            name: "div"
          }
        },
        children: [{
            type: 'JSXExpressionContainer',
            expression: {
              type: 'Identifier',
              name: 'a',
              range: [6, 7],
              loc: {
                start: {
                  line: 1,
                  column: 6
                },
                end: {
                  line: 1,
                  column: 7
                }
              }
            },
            range: [5, 8],
            loc: {
              start: {
                line: 1,
                column: 5
              },
              end: {
                line: 1,
                column: 8
              }
            }
          }, {
            type: 'JSXExpressionContainer',
            expression: {
              type: 'Identifier',
              name: 'b',
              range: [9, 10],
              loc: {
                start: {
                  line: 1,
                  column: 9
                },
                end: {
                  line: 1,
                  column: 10
                }
              }
            },
            range: [8, 11],
            loc: {
              start: {
                line: 1,
                column: 8
              },
              end: {
                line: 1,
                column: 11
              }
            }
          }
        ]
      }
    }
> node test/run.js

<div>{a}{b}</div> Unexpected token (1:11)
Normal parser: 899 tests run in 82ms; 1 failures.
Loose parser: 856 tests run in 117ms; all passed.
Total: 1755 tests run in 199ms; 1 failures.
npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0
RReverser commented 9 years ago

Seems to be automagically resolved after merging upstream and fixing conflicts :P

wadahiro commented 9 years ago

Thank you so much!