Skip to content

Commit

Permalink
JS: support ellipsis operator anywhere in arguments, fixes #373
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Feb 6, 2021
1 parent 512135e commit 29261c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
10 changes: 3 additions & 7 deletions js/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,10 @@ func (m *jsMinifier) minifyArguments(args js.Args) {
if i != 0 {
m.write(commaBytes)
}
m.minifyExpr(item, js.OpAssign)
}
if args.Rest != nil {
if len(args.List) != 0 {
m.write(commaBytes)
if item.Rest {
m.write(ellipsisBytes)
}
m.write(ellipsisBytes)
m.minifyExpr(args.Rest, js.OpAssign)
m.minifyExpr(item.Value, js.OpAssign)
}
m.write(closeParenBytes)
}
Expand Down
1 change: 1 addition & 0 deletions js/js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ func TestJS(t *testing.T) {
{`(1,2,a|3)&&b`, `1,2,a|3&&b`},
{`(a,b)?c:b`, `a,b&&c`},
{`(a,b)?c:d`, `a,b?c:d`},
{`f(...a,...b)`, `f(...a,...b)`},

// expressions
//{`a=a+5`, `a+=5`},
Expand Down

0 comments on commit 29261c3

Please sign in to comment.