Closed sebmck closed 9 years ago
Excuse the convoluted example but take for example the following:
test.js
var React = require('react'); var Thing = React.createClass({ render() { return ( <div> <div> <h1>foo</h1> <p>foo</p> <p>foo</p> <p>foo</p> <p>foo</p> <p>foo</p> <button onClick={this._handleClick}>click me</button> </div> </div> ); }, _handleClick(event) { var target = event.target; console.log(target); } }); React.render(<Thing />, document.getElementById('main'));
If you get for example <button onClick={this._handleClick}>click me</button> on line 14:
<button onClick={this._handleClick}>click me</button>
14
> require("acorn-jsx").parse(require("fs").readFileSync("test.js", "utf8"), { ecmaVersion: 6, locations: true }).body[1].declarations[0].init.arguments[0].properties[0].value.body.body[0].argument.children[1].children[13].loc; { start: { line: 20, column: 20 }, end: { line: 20, column: 73 } }
As you can see the line number is completely off.
Please see https://github.com/RReverser/acorn-jsx/issues/13#issuecomment-70367070 - situation is the same (also fixed, will be released in few days).
@RReverser Great, thank you so much!
Excuse the convoluted example but take for example the following:
test.js
If you get for example
<button onClick={this._handleClick}>click me</button>
on line14
:As you can see the line number is completely off.