[Pkg-javascript-commits] [node-acorn-jsx] 457/484: Ensure empty expression tokens ranges are correct
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:21:10 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit f1c3ddb8cdd7770de00ea577ab391d43a6530cc2
Author: Nicholas C. Zakas <nicholas at nczconsulting.com>
Date: Mon Oct 12 14:06:40 2015 -0700
Ensure empty expression tokens ranges are correct
Fixes #28
---
inject.js | 11 ++--------
test/tests-jsx.js | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 9 deletions(-)
diff --git a/inject.js b/inject.js
index eba511e..bfe0358 100644
--- a/inject.js
+++ b/inject.js
@@ -244,15 +244,8 @@ module.exports = function(acorn) {
// at the beginning of the next one (right brace).
pp.jsx_parseEmptyExpression = function() {
- var tmp = this.start;
- this.start = this.lastTokEnd;
- this.lastTokEnd = tmp;
-
- tmp = this.startLoc;
- this.startLoc = this.lastTokEndLoc;
- this.lastTokEndLoc = tmp;
-
- return this.finishNode(this.startNode(), 'JSXEmptyExpression');
+ var node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc);
+ return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc);
};
// Parses JSX expression enclosed into curly brackets.
diff --git a/test/tests-jsx.js b/test/tests-jsx.js
index f2506a9..48e6a1d 100644
--- a/test/tests-jsx.js
+++ b/test/tests-jsx.js
@@ -3634,10 +3634,76 @@ var fbTestFixture = {
if (typeof exports !== "undefined") {
var test = require("./driver.js").test;
var testFail = require("./driver.js").testFail;
+ var tokTypes = require("../").tokTypes;
}
testFail("var x = <div>one</div><div>two</div>;", "Adjacent JSX elements must be wrapped in an enclosing tag (1:22)");
+test('<a>{/* foo */}</a>', {}, {
+ onToken: [
+ {
+ type: tokTypes.jsxTagStart,
+ value: undefined,
+ start: 0,
+ end: 1
+ },
+ {
+ type: tokTypes.jsxName,
+ value: 'a',
+ start: 1,
+ end: 2
+ },
+ {
+ type: tokTypes.jsxTagEnd,
+ value: undefined,
+ start: 2,
+ end: 3
+ },
+ {
+ type: tokTypes.braceL,
+ value: undefined,
+ start: 3,
+ end: 4
+ },
+ {
+ type: tokTypes.braceR,
+ value: undefined,
+ start: 13,
+ end: 14
+ },
+ {
+ type: tokTypes.jsxTagStart,
+ value: undefined,
+ start: 14,
+ end: 15
+ },
+ {
+ type: tokTypes.slash,
+ value: '/',
+ start: 15,
+ end: 16
+ },
+ {
+ type: tokTypes.jsxName,
+ value: 'a',
+ start: 16,
+ end: 17
+ },
+ {
+ type: tokTypes.jsxTagEnd,
+ value: undefined,
+ start: 17,
+ end: 18
+ },
+ {
+ type: tokTypes.eof,
+ value: undefined,
+ start: 18,
+ end: 18
+ }
+ ]
+});
+
for (var ns in fbTestFixture) {
ns = fbTestFixture[ns];
for (var code in ns) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list