diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-03-08 20:40:21 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-09 04:40:21 +0800 |
commit | f4ee0f651c952eb85753633a990a598267981bcb (patch) | |
tree | 83fbc0251e0ea4e4091937fbe6b04c7540303aa5 /lib/compress.js | |
parent | 077512d1515d9fbd4e19bce79be75a09df8d5619 (diff) | |
download | tracifyjs-f4ee0f651c952eb85753633a990a598267981bcb.tar.gz tracifyjs-f4ee0f651c952eb85753633a990a598267981bcb.zip |
fix corner case in `unsafe` (#4755)
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 22 |
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); |