Skip to content

JSX doesn't handle an over parenthesization #1673

Closed
@sebmarkbage

Description

@sebmarkbage

This unit test fails.

  it('should handle parenthesis in expressions', function() {
    var code = [
      '/**',
      ' * @jsx React.DOM',
      ' */',
      '<Component x={(a)} {...(b)} y={1} />;'
    ].join('\n');
    var result = [
      '/**',
      ' * @jsx React.DOM',
      ' */',
      'Component({x: (a), ...(b), y: 1});'
    ].join('\n');

    expect(transform(code).code).toBe(result);
  });

Because this only steps past the inner expression: https://github.com/facebook/react/blob/master/vendor/fbtransform/transforms/xjs.js#L226-L227

The parenthesis is not it's own expression and therefore doesn't have a range. It's not possible to skip past the ) to insert the , after it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions