fix corner case in templates (#5137)

fixes #5136
This commit is contained in:
Alex Lam S.L
2021-09-30 14:43:34 +01:00
committed by GitHub
parent 157521066f
commit 0b2573c3fa
2 changed files with 23 additions and 9 deletions

View File

@@ -11374,15 +11374,6 @@ merge(Compressor.prototype, {
if (!tag) status = typeof trimmed;
}
if (!tag && strs.length > 1) {
if (strs[0] == "") return make_node(AST_Binary, self, {
operator: "+",
left: exprs[0],
right: make_node(AST_Template, self, {
expressions: exprs.slice(1),
strings: strs.slice(1),
tag: tag,
}).transform(compressor),
}).optimize(compressor);
if (strs[strs.length - 1] == "") return make_node(AST_Binary, self, {
operator: "+",
left: make_node(AST_Template, self, {
@@ -11392,6 +11383,15 @@ merge(Compressor.prototype, {
}).transform(compressor),
right: exprs[exprs.length - 1],
}).optimize(compressor);
if (strs[0] == "") return make_node(AST_Binary, self, {
operator: "+",
left: exprs[0],
right: make_node(AST_Template, self, {
expressions: exprs.slice(1),
strings: strs.slice(1),
tag: tag,
}).transform(compressor),
}).optimize(compressor);
}
self.expressions = exprs;
self.strings = strs;