Skip to content

Conversation

@sophiebits
Copy link
Collaborator

Fixes #335.

With this change, this JSX:

/** @jsx React.DOM */
var HelloMessage = React.createClass({
  render: function() {
    return <div>
      Look!
      <a href=
        "http://www.facebook.com/">Facebook
      </a>
    </div>;
  }
});

produces

/** @jsx React.DOM */
var HelloMessage = React.createClass({displayName: 'HelloMessage',
  render: function() {
    return React.DOM.div(null,
      " Look! ",
      React.DOM.a( {href:
        "http://www.facebook.com/"}, "Facebook "
      )
    );
  }
});

rather than the less-desirable

/** @jsx React.DOM */
var HelloMessage = React.createClass({displayName: 'HelloMessage',
  render: function() {
    return React.DOM.div(null,
" Look! ",      React.DOM.a( {href:"http://www.facebook.com/"}, "Facebook "      ),
    );
  }
});

Fixes facebook#335.

Now this JSX:

```
/** @jsx React.DOM */
var HelloMessage = React.createClass({
  render: function() {
    return <div>
      Look!
      <a href=
        "http://www.facebook.com/">Facebook
      </a>
    </div>;
  }
});
```

produces

```
/** @jsx React.DOM */
var HelloMessage = React.createClass({displayName: 'HelloMessage',
  render: function() {
    return React.DOM.div(null,
      " Look! ",
      React.DOM.a( {href:
        "http://www.facebook.com/"}, "Facebook "
      )
    );
  }
});
```

rather than the less-desirable

```
/** @jsx React.DOM */
var HelloMessage = React.createClass({displayName: 'HelloMessage',
  render: function() {
    return React.DOM.div(null,
" Look! ",      React.DOM.a( {href:"http://www.facebook.com/"}, "Facebook "      ),
    );
  }
});
```
@zpao
Copy link
Member

zpao commented Sep 11, 2013

@jeffmo, I'm going to leave this all to you. We should be able to figure out testing too now that jstransform is open and has tests.

@jeffmo
Copy link
Contributor

jeffmo commented Sep 11, 2013

Eyeballing this, it looks good off the top of my head; However, due to some temporary synchronization issues between the versions of these files we have checked in internally and the versions we have in github at the moment (we're behind a bit internally on react.js), I need to hold off for a day or two before I can patch this internally to run our tests against it. After that I can merge/close

Hoping to be able to do that before the end of the week though

jeffmo pushed a commit that referenced this pull request Sep 20, 2013
JSX: Respect original spacing and newlines better
@jeffmo jeffmo merged commit b5a11a4 into facebook:master Sep 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSX transform doesn't always preserve line numbers

3 participants