Skip to content

Commit 0025436

Browse files
committed
Update Acorn version and fix incompatibilities.
1 parent a4395c3 commit 0025436

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

inject.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ module.exports = function(acorn) {
196196
// Parse namespaced identifier.
197197

198198
pp.jsx_parseNamespacedName = function() {
199-
var start = this.markPosition();
199+
var startPos = this.start, startLoc = this.startLoc;
200200
var name = this.jsx_parseIdentifier();
201201
if (!this.eat(tt.colon)) return name;
202-
var node = this.startNodeAt(start);
202+
var node = this.startNodeAt(startPos, startLoc);
203203
node.namespace = name;
204204
node.name = this.jsx_parseIdentifier();
205205
return this.finishNode(node, 'JSXNamespacedName');
@@ -209,10 +209,10 @@ module.exports = function(acorn) {
209209
// or single identifier.
210210

211211
pp.jsx_parseElementName = function() {
212-
var start = this.markPosition();
212+
var startPos = this.start, startLoc = this.startLoc;
213213
var node = this.jsx_parseNamespacedName();
214214
while (this.eat(tt.dot)) {
215-
var newNode = this.startNodeAt(start);
215+
var newNode = this.startNodeAt(startPos, startLoc);
216216
newNode.object = node;
217217
newNode.property = this.jsx_parseIdentifier();
218218
node = this.finishNode(newNode, 'JSXMemberExpression');
@@ -285,8 +285,8 @@ module.exports = function(acorn) {
285285

286286
// Parses JSX opening tag starting after '<'.
287287

288-
pp.jsx_parseOpeningElementAt = function(start) {
289-
var node = this.startNodeAt(start);
288+
pp.jsx_parseOpeningElementAt = function(startPos, startLoc) {
289+
var node = this.startNodeAt(startPos, startLoc);
290290
node.attributes = [];
291291
node.name = this.jsx_parseElementName();
292292
while (this.type !== tt.slash && this.type !== tt.jsxTagEnd)
@@ -298,8 +298,8 @@ module.exports = function(acorn) {
298298

299299
// Parses JSX closing tag starting after '</'.
300300

301-
pp.jsx_parseClosingElementAt = function(start) {
302-
var node = this.startNodeAt(start);
301+
pp.jsx_parseClosingElementAt = function(startPos, startLoc) {
302+
var node = this.startNodeAt(startPos, startLoc);
303303
node.name = this.jsx_parseElementName();
304304
this.expect(tt.jsxTagEnd);
305305
return this.finishNode(node, 'JSXClosingElement');
@@ -308,23 +308,23 @@ module.exports = function(acorn) {
308308
// Parses entire JSX element, including it's opening tag
309309
// (starting after '<'), attributes, contents and closing tag.
310310

311-
pp.jsx_parseElementAt = function(start) {
312-
var node = this.startNodeAt(start);
311+
pp.jsx_parseElementAt = function(startPos, startLoc) {
312+
var node = this.startNodeAt(startPos, startLoc);
313313
var children = [];
314-
var openingElement = this.jsx_parseOpeningElementAt(start);
314+
var openingElement = this.jsx_parseOpeningElementAt(startPos, startLoc);
315315
var closingElement = null;
316316

317317
if (!openingElement.selfClosing) {
318318
contents: for (;;) {
319319
switch (this.type) {
320320
case tt.jsxTagStart:
321-
start = this.markPosition();
321+
startPos = this.start; startLoc = this.startLoc;
322322
this.next();
323323
if (this.eat(tt.slash)) {
324-
closingElement = this.jsx_parseClosingElementAt(start);
324+
closingElement = this.jsx_parseClosingElementAt(startPos, startLoc);
325325
break contents;
326326
}
327-
children.push(this.jsx_parseElementAt(start));
327+
children.push(this.jsx_parseElementAt(startPos, startLoc));
328328
break;
329329

330330
case tt.jsxText:
@@ -339,10 +339,11 @@ module.exports = function(acorn) {
339339
this.unexpected();
340340
}
341341
}
342-
if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name))
342+
if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
343343
this.raise(
344344
closingElement.start,
345345
'Expected corresponding JSX closing tag for <' + getQualifiedJSXName(openingElement.name) + '>');
346+
}
346347
}
347348

348349
node.openingElement = openingElement;
@@ -357,9 +358,9 @@ module.exports = function(acorn) {
357358
// Parses entire JSX element from current position.
358359

359360
pp.jsx_parseElement = function() {
360-
var start = this.markPosition();
361+
var startPos = this.start, startLoc = this.startLoc;
361362
this.next();
362-
return this.jsx_parseElementAt(start);
363+
return this.jsx_parseElementAt(startPos, startLoc);
363364
};
364365

365366
acorn.plugins.jsx = function(instance) {

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Alternative, faster React.js JSX parser",
44
"homepage": "https://github.com/RReverser/acorn-jsx",
55
"main": "acorn.js",
6-
"version": "1.0.3",
6+
"version": "1.1.0",
77
"maintainers": [
88
{
99
"name": "Ingvar Stepanyan",
@@ -25,10 +25,10 @@
2525
"test": "node test/run.js"
2626
},
2727
"dependencies": {
28-
"acorn": "^1.0.3"
28+
"acorn": "^1.2.2"
2929
},
3030
"devDependencies": {
31-
"chai": "^2.2.0",
32-
"mocha": "^2.2.4"
31+
"chai": "^3.0.0",
32+
"mocha": "^2.2.5"
3333
}
3434
}

0 commit comments

Comments
 (0)