Skip to content

-calc(...) gives calc() result #30

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

Closed
MoOx opened this issue Aug 10, 2017 · 9 comments
Closed

-calc(...) gives calc() result #30

MoOx opened this issue Aug 10, 2017 · 9 comments
Labels

Comments

@MoOx
Copy link
Owner

MoOx commented Aug 10, 2017

Input

div {
  margin-left: -calc(2px *2);
}

Output

div {
  margin-left: 4px;
}

Expected?

div {
  margin-left: -4px;
}

Reproducible on http://cssnext.io/playground/

@andyjansson
Copy link
Contributor

The expected value should be the same as the input, as -calc is simply invalid.

@MoOx
Copy link
Owner Author

MoOx commented Aug 13, 2017 via email

@andyjansson
Copy link
Contributor

I know. The bug is in the MATCH_CALC regex. It needs to be changed to the following:

 /^((?:\-[a-z]+\-)?calc)$/

@MoOx
Copy link
Owner Author

MoOx commented Aug 13, 2017 via email

@andyjansson
Copy link
Contributor

I already sent one.

@lkraav
Copy link

lkraav commented Aug 24, 2017

What's the next step? This seems to be affecting a couple of projects of mine.

EDIT I resolved my case by going with calc( $variable * -1 ) source css-modules/postcss-icss-values#64 (comment)

@Semigradsky
Copy link
Collaborator

Input

div {
 margin-left: -calc(2px *2);
}

Expected?

div {
 margin-left: -4px;
}

I think expected should be throwing exception because it is incorrect calc expression.

@wcandrew
Copy link

wcandrew commented Jan 4, 2018

@lkraav Solution worked for me. HERO!

@Semigradsky
Copy link
Collaborator

Closed as incorrect syntax.

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

No branches or pull requests

5 participants