Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: Fallback value incorrectly removed depending on order of other properties #1682

Copy link
Copy link

Description

@aayla-secura
Issue body actions

Describe the bug

I'm quite perplexed by this. The following input:

:root,
:root .dark-theme .light-theme {
  --col: #fff;
}

:root .dark-theme {
  --col: #333;
}

.arrow {
  border-style: solid;
  border-width: 50px;
  border-color: #fff transparent;
  border-color: var(--col) transparent;
  border-top: none;
  height: 0;
  width: 0;
}

is minified to this (prettified version):

:root,
:root .dark-theme .light-theme {
  --col: #fff;
}
:root .dark-theme {
  --col: #333;
}
.arrow {
  border: 50px solid transparent;
  border-bottom: 50px solid #fff;
  border-top: none;
  height: 0;
  width: 0;
}

Notice that the var(--col) fallback has been removed and therefore the switching to dark theme doesn't work.

If I put border-style and/or border-width below border-color it correctly preserves it:

:root,
:root .dark-theme .light-theme {
  --col: #fff;
}

:root .dark-theme {
  --col: #333;
}

.arrow {
  border-color: #fff transparent;
  border-color: var(--col) transparent;
  border-style: solid;
  border-width: 50px;
  border-top: none;
  height: 0;
  width: 0;
}

Gets minified to (prettified version):

:root,
:root .dark-theme .light-theme {
  --col: #fff;
}
:root .dark-theme {
  --col: #333;
}
.arrow {
  border-color: #fff transparent;
  border-color: var(--col) transparent;
  border-style: solid;
  border-width: 50px;
  border-top: none;
  height: 0;
  width: 0;
}

Am I correct to think it's a bug? Why would the order of border-style or border-width cause it to remove fallback properties?

Expected behaviour

I expect the fallback property to be kept either way.

Steps to reproduce

Example here: https://github.com/[aayla-secura/cssnano-issue](https://github.com/aayla-secura/cssnano-issue)

If you look at index.html which includes .arrow inside .dark-theme the arrow should be dark, and is dark when using all css versions except not-working-after-min-post.css

Version

7.0.6

Preset

(no preset)

Environment

Ubuntu on WLS2 on Windows 11

Package details

├── cssnano@7.0.6
├── postcss-cli@11.0.0
├── postcss-preset-env@10.1.2
└── postcss@8.4.49

Additional context

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.