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]: leading zero not removed for timing functions assigned to custom property #1488

Open
meduzen opened this issue Apr 7, 2023 · 1 comment

Comments

@meduzen
Copy link

meduzen commented Apr 7, 2023

Describe the bug

Leading zero is not stripped from cubic-bezier functions assigned to custom properties.

Maybe there’s some proximity with #1456.

Expected behaviour

The following

.a { animation-timing-function: cubic-bezier(0.485,0.045,0.545,0.97); }
.b { --cp: cubic-bezier(0.485,0.045,0.545,0.97); }
.c { --gr: rgb(0, 0, 0); }

minifies to

.a{animation-timing-function:cubic-bezier(.485,.045,.545,.97)}.b{--cp:cubic-bezier(0.485,0.045,0.545,0.97)}.c{--gr:#000}

We see that animation-timing-function allows cubic-bezier coordinates to be minified, while the same value assigned to a custom property isn’t.

animation-timing-function:cubic-bezier(.485,.045,.545,.97); /* leading zero removed ✅ */
--cp:cubic-bezier(0.485,0.045,0.545,0.97); /* leading zero not removed ❌ */

My expectation for assigning such a timing-function to a custom property would be that it should be minified.

Steps to reproduce

CSS Nano playground link

Version

6.0.0

Preset

(no preset)

Environment

System:
    OS: macOS 13.2.1
    CPU: no, it’s connected to hamsters
    Memory: -
    Shell: -

Package details

├─┬ cssnano@6.0.0
│ └── postcss@8.4.21
└─┬ vite@4.2.1
  └── postcss@8.4.21

Additional context

No response

@meduzen meduzen changed the title [Bug]: [Bug]: leading zero not removed for timing functions assigned to custom property Apr 7, 2023
@ludofischer
Copy link
Collaborator

At the moment, postcss-convert-values skips all transformations when it encounters a CSS property:

lowerCasedProp.indexOf('--') === 0 ||
, if I remember correctly it is because in general it is not possible to determine from the CSS property declaration whether the transformation will be correct where the CSS property is actually used. Maybe in this specific case the transformations would be safe, but from issues we've had in the past I think it's better to think twice before transforming a CSS property.

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

No branches or pull requests

2 participants