css-validator icon indicating copy to clipboard operation
css-validator copied to clipboard

calc() with comment brings unexpected result

Open mhampl opened this issue 1 year ago • 1 comments

The CSS snippet mypar { width:calc(10em /*comment*/ + 10px) } gives the error Value Error : width /*comment*/ + is an incorrect operator 10px)

When replacing the plus operator by a minus, giving the very similar code mypar { width:calc(10em /*comment*/ - 10px) } this is evaluated as valid.

A "valid" result is also given, when I remove the space character between percent sign and start of the comment indicator mypar { width:calc(10em/*comment*/ + 10px) } or when totally removing the comment.

I do not see any reason why the first example should be not valid, if all other ones are. (Check was done for CSS level 3 + SVG.)

mhampl avatar Oct 12 '24 18:10 mhampl

This is due to the difference in handling spaces before + and - in some other parts of the parser, it is a tricky bug but definitely a bug

ylafon avatar Jan 28 '25 10:01 ylafon