Fix #173.
This commit is contained in:
parent
e98176d5e9
commit
96bc831306
11
acorn.js
11
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");
|
||||
}
|
||||
|
||||
@ -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});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user