Skip to content

Commit

Permalink
JS: fix parsing of comments in expressions and keep all bang-comments…
Browse files Browse the repository at this point in the history
… at the top of the statement list, fixes #664
  • Loading branch information
tdewolff committed Jan 26, 2024
1 parent 1a6a68a commit d302269
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/fsnotify/fsnotify v1.7.0
github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2
github.com/tdewolff/argp v0.0.0-20231229133132-ebbc03b216f1
github.com/tdewolff/parse/v2 v2.7.8
github.com/tdewolff/parse/v2 v2.7.10
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2 h1:JAEbJn3j/FrhdWA9jW8
github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs=
github.com/tdewolff/argp v0.0.0-20231229133132-ebbc03b216f1 h1:/uJ4puhX8cB3Q4hCHYuuqRmMZ2+fEMu8H1OnWvLF3V4=
github.com/tdewolff/argp v0.0.0-20231229133132-ebbc03b216f1/go.mod h1:fF+gnKbmf3iMG+ErLiF+orMU/InyZIEnKVVigUjfriw=
github.com/tdewolff/parse/v2 v2.7.8 h1:1cnVqa8L63xFkc2vfRsZTM6Qy35nJpTvQ2Uvdv3vbvs=
github.com/tdewolff/parse/v2 v2.7.8/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
github.com/tdewolff/parse/v2 v2.7.10 h1:itheTX7WBPxGI1eo+8HQ6QVGH+ubr3Lpv98YJVtqqRo=
github.com/tdewolff/parse/v2 v2.7.10/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 h1:IkjBCtQOOjIn03u/dMQK9g+Iw9ewps4mCl1nB8Sscbo=
Expand Down
7 changes: 4 additions & 3 deletions js/js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,10 @@ func TestJS(t *testing.T) {
{`"\x00\x31 \0\u0000"`, `"\x001 \0\x00"`}, // #577
{`function transform(){{var aaaa=[];for(var b=0;;){}for(var b in aaaa){}var aaaa=[];for(var b=0;;){}}}`, `function transform(){{for(var aaaa=[],b=0;;);for(b in aaaa);for(aaaa=[],b=0;;);}}`}, // #619
{`for(var a=0;;){var b=5;for(var c=0;;);}`, `for(var b,c,a=0;;)for(b=5,c=0;;);`}, // #634
{"if(a)for(;;)\n;else b", `if(a)for(;;);else b`}, // #636
{`'\u000A\u000D'`, "`\n\r`"}, // #653
{`for(!a;b;c);`, "for(!a;b;c);"}, // #656
{"if(a)for(;;)\n;else b", `if(a)for(;;);else b`}, // #636
{`'\u000A\u000D'`, "`\n\r`"}, // #653
{`for(!a;b;c);`, "for(!a;b;c);"}, // #656
{"var a = /*! comment */ b;", "/*! comment */var a=b"}, // #664
}

m := minify.New()
Expand Down

0 comments on commit d302269

Please sign in to comment.