Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Fix source location for JSXEmptyExpression nodes (fixes #248) (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlongster authored and hzoo committed Dec 14, 2016
1 parent 4958225 commit ba96b91
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/plugins/jsx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ pp.jsxParseAttributeValue = function() {
// at the beginning of the next one (right brace).

pp.jsxParseEmptyExpression = function() {
let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
return this.finishNodeAt(node, "JSXEmptyExpression", this.start, this.startLoc);
let node = this.startNodeAt(this.state.lastTokEnd, this.state.lastTokEndLoc);
return this.finishNodeAt(node, "JSXEmptyExpression", this.state.start, this.state.startLoc);
};

// Parse JSX spread child
Expand Down
39 changes: 16 additions & 23 deletions test/fixtures/jsx/basic/10/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,20 @@
},
"expression": {
"type": "JSXEmptyExpression",
"loc": {},
"leadingComments": [
"start": 4,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 27
}
},
"leadingComments": null,
"innerComments": [
{
"type": "CommentBlock",
"value": " this is a comment ",
Expand All @@ -156,26 +168,7 @@
}
}
]
},
"leadingComments": null,
"innerComments": [
{
"type": "CommentBlock",
"value": " this is a comment ",
"start": 4,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 27
}
}
}
]
}
}
]
}
Expand All @@ -201,4 +194,4 @@
}
}
]
}
}

0 comments on commit ba96b91

Please sign in to comment.