Skip to content

Commit bc77df5

Browse files
authored
Merge pull request #746 from VastBlast/fix-issue-745
Respect ES Version, fixes #745
2 parents 400c636 + d10da8a commit bc77df5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

js/util.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,13 @@ func (m *jsMinifier) optimizeCondExpr(expr *js.CondExpr, prec js.OpPrec) js.IExp
822822
} else if isEqualExpr(expr.X, expr.Y) {
823823
// if true and false bodies are equal
824824
return groupExpr(&js.CommaExpr{[]js.IExpr{expr.Cond, expr.X}}, prec)
825-
} else if nullishExpr, ok := toNullishExpr(expr); ok && m.o.minVersion(2020) {
826-
// no need to check whether left/right need to add groups, as the space saving is always more
827-
return nullishExpr
828825
} else {
826+
if m.o.minVersion(2020) {
827+
if nullishExpr, ok := toNullishExpr(expr); ok {
828+
// no need to check whether left/right need to add groups, as the space saving is always more
829+
return nullishExpr
830+
}
831+
}
829832
callX, isCallX := expr.X.(*js.CallExpr)
830833
callY, isCallY := expr.Y.(*js.CallExpr)
831834
if isCallX && isCallY && len(callX.Args.List) == 1 && len(callY.Args.List) == 1 && !callX.Args.List[0].Rest && !callY.Args.List[0].Rest && isEqualExpr(callX.X, callY.X) {

0 commit comments

Comments
 (0)