-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two CSS formatting bugs in se clean #745
Conversation
Thanks! I'm not sure if the tests are correct. The |
It depends on what the tests are supposed to do, I think. :) My intention was to test the changes in this patch. The test is limited to this bugfix, and I think it does that:
The test is a bit short, but I think it covers most of the angles: it demonstrates the bug, it demonstrates the fix, and it shows that there is no regression. Now, you're right, this doesn't test whether "the formatter" still works. But shouldn't that ideally be covered by other tests? I could add some random CSS here, but that would have very little to do with the changes introduced by these two patches. Are there any specific things you would want to test here? I believe there are currently no other CSS tests for |
The tests are for testing the behavior of the tool as a whole, not for testing individual PRs. So, you should update the test so that the tool to performs the expected operations given raw/incorrect input. |
You're right that there might not be a test for |
Alright, something like this? I also merged the two test-cases now in a single file, so that leaves room for other tests in the future. |
Yes, perfect. Thanks! |
This addresses two small issues with the CSS formatting in
se clean
.An incorrect space is inserted between two
::
, if these colons follow an opening(
.is currently changed to
The regex responsible for this sees the opening
(
and then adds a space after the first:
it finds. The comment in the code explains that this is to fix the colon in media queries such as(prefers-color-scheme: dark)
, but it also affects colons outside the parentheses.This can be fixed by making the regex stop at the closing
)
. I think this shouldn't break anything else. The media query example still works.Strings in the CSS output are not escaped. The raw string from the parser is directly written to the cleaned output.
If the string contains any quotes or newlines,
se clean
produces invalid CSS:is currently changed to
The patch uses the tinycss
token.representation
, which is a quoted and escaped version of the string.