diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-02-22 15:59:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-22 23:59:28 +0800 |
commit | e535f1918915251681df6ffe80a56d56672685ea (patch) | |
tree | 23a331f65e2b2d1265005331167928519d3e127b /lib/compress.js | |
parent | f9a2a9d78e8437d8b9591e97ab280e20b9442b35 (diff) | |
download | tracifyjs-e535f1918915251681df6ffe80a56d56672685ea.tar.gz tracifyjs-e535f1918915251681df6ffe80a56d56672685ea.zip |
fix corner case in `templates` (#4677)
fixes #4676
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js index c6451012..c16639fb 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -10141,8 +10141,9 @@ merge(Compressor.prototype, { OPT(AST_Template, function(self, compressor) { if (!compressor.option("templates")) return self; if (!self.tag || is_raw_tag(compressor, self.tag)) { - var exprs = self.expressions; - var strs = self.strings; + var exprs = self.expressions.slice(); + var strs = self.strings.slice(); + var CHANGED = false; for (var i = exprs.length; --i >= 0;) { var node = exprs[i]; var ev = node.evaluate(compressor); @@ -10163,6 +10164,11 @@ merge(Compressor.prototype, { }).evaluate(compressor)) continue; exprs.splice(i, 1); strs.splice(i, 2, combined); + CHANGED = true; + } + if (CHANGED) { + self.expressions = exprs; + self.strings = strs; } } return try_evaluate(compressor, self); |