Comments and whitespace in a complicated selector are not seen by stringifier
Given a sheet
.foo,
.bar,
/* comment */
.baz {
border: 2px solid black;
}
and a stringifier
class Stringifer extends shadyCssParser.Stringifier {
comment() {
return '';
}
}
Output is expected to be
.foo,.bar,.baz{border:2px solid black;}
but is instead
.foo,
.bar,
/* comment */
.baz {border:2px solid black;}
This is slightly tricky to fix in the parser without adding a significant number of costly conditional checks, but it's actually quite trivial and cheap to fix with a specialized Tokenizer. tokenizeComment could be specialized to always return a zero-length token that starts and ends at the detected offset of the comment token.
In order to support this, the Parser would have to accept a specialized Tokenizer implementation. I'm going to add this for the near term, which should allow you to address this case. If there is a more elegant solution or preferred ergonomics to be had, I'm open to considering it.
An example of the specialized tokenizeComment method:
tokenizeComment(...args) {
let token = super.tokenizeComment(...args);
// Force token to be zero length
token.start = token.end;
return token;
}
Okay, now that I think about it more, this would not be a sufficient solution. We only look at the start and end tokens when slicing chunks of the string, so the ranges in any interstitial comment tokens won't matter.