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

[Bug]: % symbol getting stripped from zero on percentage-only values #1612

Closed
Yurickh opened this issue May 8, 2024 · 2 comments · Fixed by #1632
Closed

[Bug]: % symbol getting stripped from zero on percentage-only values #1612

Yurickh opened this issue May 8, 2024 · 2 comments · Fixed by #1632
Labels

Comments

@Yurickh
Copy link

Yurickh commented May 8, 2024

Describe the bug

The % symbol is getting stripped from zero values on rules where unitless values are not supported, causing those rules to break.

Expected behaviour

Expected that when running cssnano on the following piece of css:

.potato {
  background-color: color-mix(#000, #FFF 0%);
}

it wouldn't remove the % sign, as that invalidates the color rule.

Steps to reproduce

  1. Clone my repo at https://github.com/Yurickh/cssnano-issue-repro
  2. Run npm install && npm run minify
  3. Verify that the output.css file doesn't have a % sign.

Version

6 and 7

Preset

default

Environment

System:
    OS: macOS 14.4.1
    CPU: (12) arm64 Apple M2 Pro
    Memory: 4.57 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh

Package details

cssnano-issue-repro@1.0.0 /Users/YHAUSCHI/github/oss/cssnano-issue-repro
├─┬ cssnano@7.0.1
│ ├─┬ cssnano-preset-default@7.0.1
│ │ ├─┬ css-declaration-sorter@7.2.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ cssnano-utils@5.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-calc@10.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-colormin@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-convert-values@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-discard-comments@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-discard-duplicates@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-discard-empty@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-discard-overridden@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-merge-longhand@7.0.0
│ │ │ ├── postcss@8.4.38 deduped
│ │ │ └─┬ stylehacks@7.0.0
│ │ │   └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-merge-rules@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-minify-font-values@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-minify-gradients@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-minify-params@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-minify-selectors@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-normalize-charset@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-normalize-display-values@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-normalize-positions@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-normalize-repeat-style@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-normalize-string@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-normalize-timing-functions@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-normalize-unicode@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-normalize-url@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-normalize-whitespace@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-ordered-values@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-reduce-initial@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-reduce-transforms@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-svgo@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ ├─┬ postcss-unique-selectors@7.0.0
│ │ │ └── postcss@8.4.38 deduped
│ │ └── postcss@8.4.38 deduped
│ └── postcss@8.4.38 deduped
├─┬ postcss-cli@11.0.0
│ ├─┬ postcss-load-config@5.1.0
│ │ └── postcss@8.4.38 deduped
│ ├─┬ postcss-reporter@7.1.0
│ │ └── postcss@8.4.38 deduped
│ └── postcss@8.4.38 deduped
└── postcss@8.4.38

Additional context

No response

@pgregorova
Copy link

I have been experiencing similar issue on a project where no matter how I enter the values for box-shadow, whether it is:
rgba(255,255,255,.7) 0 0 0 4000px inset or #ffffffb8 0 0 0 4000px inset
the output always ends up as:
inset 0 0 0 250pc hsla(0,0,100%,.7215686275) instead of
inset 0 0 0 250pc hsla(0,0%,100%,.7215686275), which makes it invalid as it is omitting % from the second 0

@ludofischer
Copy link
Collaborator

I have been experiencing similar issue on a project where no matter how I enter the values for box-shadow, whether it is: rgba(255,255,255,.7) 0 0 0 4000px inset or #ffffffb8 0 0 0 4000px inset the output always ends up as: inset 0 0 0 250pc hsla(0,0,100%,.7215686275) instead of inset 0 0 0 250pc hsla(0,0%,100%,.7215686275), which makes it invalid as it is omitting % from the second 0

I cannot reproduce your issue. It seems to work on the Playground too? https://cssnano.github.io/cssnano/playground/ Have you got any more details like the preset and maybe Browserslist configuration>

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

Successfully merging a pull request may close this issue.

3 participants