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

Remove whitespace inside calc() #625

Closed
valtlai opened this issue Oct 3, 2018 · 2 comments
Closed

Remove whitespace inside calc() #625

valtlai opened this issue Oct 3, 2018 · 2 comments

Comments

@valtlai
Copy link

valtlai commented Oct 3, 2018

If I have code like this

.foo {
   font-size: calc(var(--h) * 1em);
   margin-top: calc(1.5em / var(--h));
}

it can be minified to

.foo{font-size:calc(var(--h)*1em);margin-top:calc(1.5em/var(--h))}

but it gets minified to

.foo{font-size:calc(var(--h) * 1em);margin-top:calc(1.5em / var(--h))}

So could cssnano remove whitespace around * or / inside calc()?

It’s allowed by the spec:

white space is required on both sides of the ‘+’ and ‘-’ operators. (The ‘*’ and ‘/’ operaters can be used without white space around them.)


If I have code like this

.foo {
  --a: calc(var(--x, 1) * 10vw);
  --b: var(--x, 1);
}

it gets minified to

.foo{--a:calc(var(--x, 1) * 10vw);--b:var(--x,1)}

So the space after the comma is not removed inside calc(), but is outside calc().

@valtlai valtlai changed the title Remove whitespace inside calc() Remove whitespace around * & / operators inside calc() Oct 3, 2018
@valtlai valtlai changed the title Remove whitespace around * & / operators inside calc() Remove whitespace around * & / operators Oct 3, 2018
@valtlai valtlai changed the title Remove whitespace around * & / operators Remove whitespace inside calc() Oct 3, 2018
@andyjansson
Copy link
Contributor

Fixed in upstream package.

@valtlai
Copy link
Author

valtlai commented Oct 18, 2018

The second one is not fixed yet!

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