Menu

#59 fully support calc syntax

0.9.25
closed
RBRi
None
1
2020-10-24
2016-01-27
ueli kunz
No

It would be nice to have calc parser accept * (mutliplication) and spaces:

these fail at the moment:

width: calc(5*2rem);
width: calc(100% - 2rem);

that works:

width: calc(100%-2rem);

ref: https://www.w3.org/TR/css3-values/#calc-notation

Discussion

  • RBRi

    RBRi - 2016-05-23
    • status: open --> accepted
    • assigned_to: RBRi
    • Group: 0.9.19 --> 0.9.20
     
  • RBRi

    RBRi - 2016-07-23
    • Group: 0.9.20 --> 0.9.21
     
  • Daniel Peintner

    Daniel Peintner - 2016-08-22

    I support this request given that it seems quite common to have spaces in calc expressions.

    Thanks!

     
  • Anonymous

    Anonymous - 2016-08-25

    Me too, We have some calc expression which cause problems when we use your lib..
    Thanks !

     

    Last edit: Anonymous 2016-08-25
  • RBRi

    RBRi - 2016-08-25

    Sorry folks for the slow process with this. But my time is really limited. I have a real job >40h and a real family and too many projects i'm working on (https://www.openhub.net/accounts/RBRi/positions) in my spare time.

    Every patch is very welcome.

     
  • RBRi

    RBRi - 2017-01-08
    • Group: 0.9.21 --> 0.9.22
     
  • RBRi

    RBRi - 2017-01-08

    sorry had to postpone this again but work has already started

     
  • RBRi

    RBRi - 2017-02-23
    • Group: 0.9.22 --> 0.9.23
     
  • RBRi

    RBRi - 2017-06-01
    • Group: 0.9.23 --> 0.9.24
     
  • RBRi

    RBRi - 2017-10-31
    • Group: 0.9.24 --> 0.9.25
     
  • Anonymous

    Anonymous - 2018-01-03

    Any progress on this issue? :)

     
  • Olav Viitmann

    Olav Viitmann - 2018-01-04

    Would really appreciate on any update on this issue.
    Waiting forward for the fix.

    New year, new hopes :)

     
  • Anonymous

    Anonymous - 2019-05-05

    +1 for this bug, really important for us.

    Also, when printing the CSS after parsing the aritmetic char is gone :

    .myDiv { max-width:calc(100%-50px)  } 
    

    prints :

    .myDiv { max-width:calc(100% 50px)  } 
    
     
  • Christian Morgner

    Hi,

    I just submitted a patch that adds experimental support for calc(): https://sourceforge.net/p/cssparser/patches/11/

    Best,
    Christian

     
  • RBRi

    RBRi - 2020-10-07

    done with 0.9.28

     
  • RBRi

    RBRi - 2020-10-07
    • status: accepted --> closed
     
  • Carlos Amengual

    Carlos Amengual - 2020-10-24

    Hi,

    From what I'm seeing in my tests, when a calc() with a sub-expression is processed, like:

    calc((-3em)*2)

    the (-3em) part is classified as a function (SAC_FUNCTION) instead of SAC_SUB_EXPRESSION. The problem is that the first operand (the -3em in that example) returns a null identifier (SAC_IDENT with value null) when getPreviousLexicalUnit() is called on it, and my Object Model breaks there during a verification process. I have a similar issue when a var() function is found inside a calc().

    Moreover, my custom-calc tests also break, and it would be handy if the calc() processing also applied to things ending with "-calc", like -webkit-calc() which sometimes still shows up out there.

    Neither of those issues are really important to me, and I'm not asking you to spend a significant amount of time on them, but I'm reporting just in case they are low-hanging fruit, easy to fix... 🙂

     

Anonymous
Anonymous

Add attachments
Cancel