[Pkg-javascript-commits] [node-acorn-jsx] 353/484: Fix #173.
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:55 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 96bc831306dcd056624224fb64d4e640f28d0e57
Author: Ingvar Stepanyan <me at rreverser.com>
Date: Sun Dec 7 19:55:31 2014 +0200
Fix #173.
---
acorn.js | 11 +++--------
test/tests-harmony.js | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/acorn.js b/acorn.js
index daa502a..8795639 100644
--- a/acorn.js
+++ b/acorn.js
@@ -803,12 +803,6 @@
return finishToken(_dollarBraceL);
}
}
-
- if (code === 125) { // '}'
- ++tokPos;
- return finishToken(_braceR, undefined, false);
- }
-
// anything else is considered string literal
return readTmplString();
}
@@ -2153,10 +2147,11 @@
// Parse template expression.
function parseTemplate() {
+ var oldInTemplate = inTemplate;
+ inTemplate = true;
var node = startNode();
node.expressions = [];
node.quasis = [];
- inTemplate = true;
next();
for (;;) {
var elem = startNode();
@@ -2176,7 +2171,7 @@
tokPos = tokEnd;
expect(_braceR);
}
- inTemplate = false;
+ inTemplate = oldInTemplate;
next();
return finishNode(node, "TemplateLiteral");
}
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
index 15e3b98..50fe007 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -14191,3 +14191,44 @@ test("import foo, * as bar from 'baz';", {
}
}]
}, {ecmaVersion: 6});
+
+// https://github.com/marijnh/acorn/issues/173
+test("`{${x}}`, `}`", {
+ type: "Program",
+ body: [{
+ type: "ExpressionStatement",
+ expression: {
+ type: "SequenceExpression",
+ expressions: [
+ {
+ type: "TemplateLiteral",
+ expressions: [{
+ type: "Identifier",
+ name: "x"
+ }],
+ quasis: [
+ {
+ type: "TemplateElement",
+ value: {cooked: "{", raw: "{"},
+ tail: false
+ },
+ {
+ type: "TemplateElement",
+ value: {cooked: "}", raw: "}"},
+ tail: true
+ }
+ ]
+ },
+ {
+ type: "TemplateLiteral",
+ expressions: [],
+ quasis: [{
+ type: "TemplateElement",
+ value: {cooked: "}", raw: "}"},
+ tail: true
+ }]
+ }
+ ]
+ }
+ }]
+}, {ecmaVersion: 6});
--
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