Fix nlb property for template strings tokens starting with nlb
Also add .gitattributes to checkout lf eol style
This commit is contained in:
committed by
Richard van Velzen
parent
0aa526e72c
commit
1b2c02c944
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.js text eol=lf
|
||||||
@@ -497,10 +497,10 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|||||||
S.template_braces.push(S.brace_counter);
|
S.template_braces.push(S.brace_counter);
|
||||||
}
|
}
|
||||||
var content = "", raw = "", ch, tok;
|
var content = "", raw = "", ch, tok;
|
||||||
next();
|
next(true, true);
|
||||||
while ((ch = next(true)) !== "`") {
|
while ((ch = next(true, true)) !== "`") {
|
||||||
if (ch === "$" && peek() === "{") {
|
if (ch === "$" && peek() === "{") {
|
||||||
next();
|
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);
|
||||||
tok.begin = begin;
|
tok.begin = begin;
|
||||||
|
|||||||
@@ -341,3 +341,39 @@ escape_dollar_curly: {
|
|||||||
}
|
}
|
||||||
expect_exact: "console.log(`\\${ beep }`);console.log(`1\\${2-0}\\${3-0}4`);console.log(`\\${not an expression}`);"
|
expect_exact: "console.log(`\\${ beep }`);console.log(`1\\${2-0}\\${3-0}4`);console.log(`\\${not an expression}`);"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template_starting_with_newline: {
|
||||||
|
options = {
|
||||||
|
dead_code: true
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function foo(e) {
|
||||||
|
return `
|
||||||
|
this is a template string!`;
|
||||||
|
};
|
||||||
|
} expect_exact: "function foo(e){return`\nthis is a template string!`}"
|
||||||
|
}
|
||||||
|
|
||||||
|
template_with_newline: {
|
||||||
|
options = {
|
||||||
|
dead_code: true
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function foo(e) {
|
||||||
|
return `yep,
|
||||||
|
this is a template string!`;
|
||||||
|
};
|
||||||
|
} expect_exact: "function foo(e){return`yep,\nthis is a template string!`}"
|
||||||
|
}
|
||||||
|
|
||||||
|
template_ending_with_newline: {
|
||||||
|
options = {
|
||||||
|
dead_code: true
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function foo(e) {
|
||||||
|
return `this is a template string!
|
||||||
|
`;
|
||||||
|
};
|
||||||
|
} expect_exact: "function foo(e){return`this is a template string!\n`}"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user