@@ -446,7 +446,7 @@ var AST_PrefixedTemplateString = DEFNODE("PrefixedTemplateString", "template_str
|
|||||||
var AST_TemplateString = DEFNODE("TemplateString", "segments", {
|
var AST_TemplateString = DEFNODE("TemplateString", "segments", {
|
||||||
$documentation: "A template string literal",
|
$documentation: "A template string literal",
|
||||||
$propdoc: {
|
$propdoc: {
|
||||||
segments: "[AST_TemplateSegment|AST_Expression]* One or more segments, starting with AST_TemplateSegment. AST_Expression may follow AST_TemplateSegment, but each AST_Expression must be followed by AST_TemplateSegment."
|
segments: "[AST_Node*] One or more segments, starting with AST_TemplateSegment. AST_Node may follow AST_TemplateSegment, but each AST_Node must be followed by AST_TemplateSegment."
|
||||||
},
|
},
|
||||||
_walk: function(visitor) {
|
_walk: function(visitor) {
|
||||||
return visitor._visit(this, function(){
|
return visitor._visit(this, function(){
|
||||||
|
|||||||
@@ -509,8 +509,11 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|||||||
}
|
}
|
||||||
var content = "", raw = "", ch, tok;
|
var content = "", raw = "", ch, tok;
|
||||||
next(true, true);
|
next(true, true);
|
||||||
while ((ch = next(true, true)) !== "`") {
|
while ((ch = next(true, true)) != "`") {
|
||||||
if (ch === "$" && peek() === "{") {
|
if (ch == "\r") {
|
||||||
|
if (peek() == "\n") ++S.pos;
|
||||||
|
ch = "\n";
|
||||||
|
} else if (ch == "$" && peek() == "{") {
|
||||||
next(true, true);
|
next(true, true);
|
||||||
S.brace_counter++;
|
S.brace_counter++;
|
||||||
tok = token(begin ? "template_head" : "template_substitution", content);
|
tok = token(begin ? "template_head" : "template_substitution", content);
|
||||||
@@ -521,7 +524,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
raw += ch;
|
raw += ch;
|
||||||
if (ch === "\\") {
|
if (ch == "\\") {
|
||||||
var tmp = S.pos;
|
var tmp = S.pos;
|
||||||
ch = read_escaped_char();
|
ch = read_escaped_char();
|
||||||
raw += S.text.substr(tmp, S.pos - tmp);
|
raw += S.text.substr(tmp, S.pos - tmp);
|
||||||
|
|||||||
@@ -30,4 +30,13 @@ describe("Template string", function() {
|
|||||||
assert.throws(exec(tests[i]), fail, tests[i]);
|
assert.throws(exec(tests[i]), fail, tests[i]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
it("Should process all line terminators as LF", function() {
|
||||||
|
[
|
||||||
|
"`a\rb`",
|
||||||
|
"`a\nb`",
|
||||||
|
"`a\r\nb`",
|
||||||
|
].forEach(function(code) {
|
||||||
|
assert.strictEqual(uglify.parse(code).print_to_string(), "`a\\nb`;");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user