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

Commit ba96b91

Browse files
jlongsterhzoo
authored andcommitted
Fix source location for JSXEmptyExpression nodes (fixes #248) (#249)
1 parent 4958225 commit ba96b91

2 files changed

Lines changed: 18 additions & 25 deletions

File tree

src/plugins/jsx/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ pp.jsxParseAttributeValue = function() {
261261
// at the beginning of the next one (right brace).
262262

263263
pp.jsxParseEmptyExpression = function() {
264-
let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
265-
return this.finishNodeAt(node, "JSXEmptyExpression", this.start, this.startLoc);
264+
let node = this.startNodeAt(this.state.lastTokEnd, this.state.lastTokEndLoc);
265+
return this.finishNodeAt(node, "JSXEmptyExpression", this.state.start, this.state.startLoc);
266266
};
267267

268268
// Parse JSX spread child

test/fixtures/jsx/basic/10/expected.json

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,20 @@
137137
},
138138
"expression": {
139139
"type": "JSXEmptyExpression",
140-
"loc": {},
141-
"leadingComments": [
140+
"start": 4,
141+
"end": 27,
142+
"loc": {
143+
"start": {
144+
"line": 1,
145+
"column": 4
146+
},
147+
"end": {
148+
"line": 1,
149+
"column": 27
150+
}
151+
},
152+
"leadingComments": null,
153+
"innerComments": [
142154
{
143155
"type": "CommentBlock",
144156
"value": " this is a comment ",
@@ -156,26 +168,7 @@
156168
}
157169
}
158170
]
159-
},
160-
"leadingComments": null,
161-
"innerComments": [
162-
{
163-
"type": "CommentBlock",
164-
"value": " this is a comment ",
165-
"start": 4,
166-
"end": 27,
167-
"loc": {
168-
"start": {
169-
"line": 1,
170-
"column": 4
171-
},
172-
"end": {
173-
"line": 1,
174-
"column": 27
175-
}
176-
}
177-
}
178-
]
171+
}
179172
}
180173
]
181174
}
@@ -201,4 +194,4 @@
201194
}
202195
}
203196
]
204-
}
197+
}

0 commit comments

Comments
 (0)