Cssnano: [Bug] : broken declarations due to unitless 0 inside `max()`

Created on 10 Apr 2020  路  5Comments  路  Source: cssnano/cssnano

Describe the bug
cssnano is messing with 0-like values inside max() (most likely min() and clamp() too).

Note: Because <number-token>s are always interpreted as <number>s or <integer>s, "unitless 0" <length>s aren鈥檛 supported in math functions. That is, width: calc(0 + 5px); is invalid, because it鈥檚 trying to add a <number> to a <length>, even though both width: 0; and width: 5px; are valid.

To Reproduce
Steps to reproduce the behavior:

  1. Open the playground on a new tab https://cssnano.co/playground/
  2. Paste the following code
/* Your CSS here */
.invalid_pb-0-safe { padding-bottom: max(0, env(safe-area-inset-bottom)); }
.valid_broken_1_pb-0-safe { padding-bottom: max(0px, env(safe-area-inset-bottom)); }
.valid_broken_2_pb-0-safe { padding-bottom: max(calc(0 * 1px), env(safe-area-inset-bottom)); }
.valid_working_pb-0-safe { padding-bottom: max(0 * 1px, env(safe-area-inset-bottom)); }

Expected behavior

  • .invalid_pb-0-safe: invalid because it contains unitless values. Can be dropped
  • .valid_broken_1_pb-0-safe: valid because it doesn't contain unitless values. Should be kept untouched
  • .valid_broken_2_pb-0-safe: valid because it doesn't contain unitless values. Should be kept although it might be better to compute and keep as 0px
  • .valid_working_pb-0-safe: valid and currently the only way to prevent cssnano from messing with it (?). Should be kept as is (already working, no need to change anything for this one)

Screenshots
If applicable, add screenshots to help explain your problem. (from cssnano-playground)

Desktop (please complete the following information):

  • Whatever the playground is using.

Additional context
Revelant links to the spec:

Encountered the issue when testing for a patch for this other project here: https://github.com/desaintflorent/tailwindcss-padding-safe/issues/1

All 5 comments

This has been fixed here https://github.com/cssnano/cssnano/pull/894
it will be released soon.

Let me know if there is anything specific you are looking for !

@anikethsaha still not published?

We are still looking for few bugs to fixed and then we will release a major.

In the meantime, use cssnano@nightly it is up to date with the master of this repo

Let's close

Missed this back in April but I still wanted to thank you all for the fix 鉂わ笍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bernhardreiter picture bernhardreiter  路  7Comments

daviestar picture daviestar  路  7Comments

matanarbel-startapp picture matanarbel-startapp  路  6Comments

GrimLink picture GrimLink  路  7Comments

tiendq picture tiendq  路  7Comments