Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -895,11 +895,13 @@ export class Packer {
// - `/.../ in b` vs. `/.../in b`; also applies to other names or number literals
// starting with digits, but only `in` and `instanceof` are possible in the valid JS.
// - `a + + b` vs. `a ++ b`
// - `a + ++ b` vs. `a +++ b`
// - `a - - b` vs. `a -- b`
// - `a - -- b` vs. `a --- b`
// - short HTML comments only recognized in web browsers:
// - `a < ! --b` vs. `a <!--b`
// - `a-- > b` vs. `a-->b`
(prevToken.value + ' ' + token.value).match(/^\/ \/|\/ in(?:stanceof)?$|^(?:\+ \+|- -|! --|-- >)$/)
(prevToken.value + ' ' + token.value).match(/^\/ \/|\/ in(?:stanceof)?$|^(?:\+ \+\+?|- --?|! --|-- >)$/)
)) {
if (prevToken.abbr) {
if (token.abbr) {
Expand Down
2 changes: 2 additions & 0 deletions test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ test('prepareJs without abbrs', t => {
t.is(prepare(`switch (3) { case .3: ; }`), `switch(3){case.3:;}`);
t.is(prepare(`switch (3) { case ㅎ: ; }`), `switch(3){case \\u314e:;}`);
t.is(prepare(`for (const a of $tuffs) {}`), `for(const a of $tuffs){}`);
t.is(prepare(`a + ++b`), `a+ ++b`);
t.is(prepare(`a - --b`), `a- --b`);
});

//------------------------------------------------------------------------------
Expand Down