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

Bad order of border-color rules when using var with multiple border-color statements. #1128

Closed
MariusKarthaus opened this issue Oct 21, 2020 · 1 comment
Labels

Comments

@MariusKarthaus
Copy link

Environment

clean-css@4.2.3
node @ v14.14.0
os linux

Input CSS

:root{
    --border-opacity: 1;
}
.mytest {
  border-color: #3182ce;
  border-color: rgba(49, 130, 206, var(--border-opacity));
  border-top-color: transparent;
}

Actual output CSS

:root {
  --border-opacity: 1;
}
.mytest {
  border-color: transparent #3182ce #3182ce;
  border-color: rgba(49, 130, 206, var(--border-opacity));
}

Expected output CSS

:root {
  --border-opacity: 1;
}
.mytest {
  border-color: rgba(49, 130, 206, var(--border-opacity));
  border-color: transparent #3182ce #3182ce;
}

The issue is arose when using tailwind's @apply border-blue-600 which pulls in the two border-color rules, and then wanting to hide parts of the border.

@jakubpawlowicz
Copy link
Collaborator

jakubpawlowicz commented Jan 27, 2021

Hey @MariusKarthaus - I believe the correct output should be

:root{
    --border-opacity: 1;
}
.mytest {
  border-color: #3182ce;
  border-color: rgba(49, 130, 206, var(--border-opacity));
  border-top-color: transparent;
}

which is the same as input.

The reason are

  • border-color: #3182ce; can't be moved after border-color: rgba(49, 130, 206, var(--border-opacity)); as the latter is an override which is handled by browsers understanding rgba() and variables
  • we can't pull border-top-color: transparent; into both border-colors as it'd result in a longer content

But your bug fix is still valid - clean-css is wrong getting rid of the border-top-color. Let me fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants