Skip to content
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

fix(postcss-ordered-values): preserve columns count #1144

Merged
merged 2 commits into from Jun 7, 2021
Merged

Conversation

@ludofischer
Copy link
Collaborator

@ludofischer ludofischer commented Jun 5, 2021

Fix #1123

  • rewrite columns handling logic
  • add tests
Copy link
Collaborator Author

@ludofischer ludofischer left a comment

We only want to do something when one value of the columns declaration has a unit (so is a width) and the other not. All other cases are either invalid or cannot be optimized through reordering. So the new code collects the widths and other types of values separately as it walks the tree, and reorders only if the condition holds at the end. If we stop as soon as two values are found, then we might make some invalid declarations valid and change the effect of the CSS.

columns.walk((node) => {
const { type, value } = node;
if (type === 'word' && strValues.indexOf(value.toLowerCase())) {
Copy link
Collaborator Author

@ludofischer ludofischer Jun 5, 2021

I don't understand what the old code is trying to do. This seems a strange way to check if

value.toLowerCase() !== 'auto'

(since it the only case where indexOf returns 0 )

Fix #1123

* rewrite columns handling logic
* add tests
@ludofischer ludofischer changed the title fix(postcss-ordered-values): preserve columns values fix(postcss-ordered-values): preserve columns count Jun 5, 2021
@ludofischer ludofischer merged commit 9acd6a2 into master Jun 7, 2021
10 checks passed
@ludofischer ludofischer deleted the fix-columns branch Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants