aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-03-08 20:40:21 +0000
committerGitHub <noreply@github.com>2021-03-09 04:40:21 +0800
commitf4ee0f651c952eb85753633a990a598267981bcb (patch)
tree83fbc0251e0ea4e4091937fbe6b04c7540303aa5 /lib/compress.js
parent077512d1515d9fbd4e19bce79be75a09df8d5619 (diff)
downloadtracifyjs-f4ee0f651c952eb85753633a990a598267981bcb.tar.gz
tracifyjs-f4ee0f651c952eb85753633a990a598267981bcb.zip
fix corner case in `unsafe` (#4755)
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/compress.js b/lib/compress.js
index f63c1869..a92ad97d 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -8581,17 +8581,17 @@ merge(Compressor.prototype, {
break;
case "charAt":
if (self.args.length < 2) {
- var node = make_node(AST_Sub, self, {
- expression: exp.expression,
- property: self.args.length ? make_node(AST_Binary, self.args[0], {
- operator: "|",
- left: make_node(AST_Number, self, {
- value: 0
- }),
- right: self.args[0]
- }) : make_node(AST_Number, self, {
- value: 0
- })
+ var node = make_node(AST_Binary, self, {
+ operator: "||",
+ left: make_node(AST_Sub, self, {
+ expression: exp.expression,
+ property: self.args.length ? make_node(AST_Binary, self.args[0], {
+ operator: "|",
+ left: make_node(AST_Number, self, { value: 0 }),
+ right: self.args[0],
+ }) : make_node(AST_Number, self, { value: 0 }),
+ }).optimize(compressor),
+ right: make_node(AST_String, self, { value: "" }),
});
node.is_string = return_true;
return node.optimize(compressor);