sabberworm / PHP-CSS-Parser

A Parser for CSS Files written in PHP. Allows extraction of CSS files into a data structure, manipulation of said structure and output as (optimized) CSS

Home Page:http://www.sabberworm.com/blog/2010/6/10/php-css-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

calc() inside rgb() is causing the value to be stripped out

Tabrisrp opened this issue · comments

When using calc() inside a rgb() value, after parsing the corresponding property is getting stripped out completely from the tokens.

An example:

.dark{
    background: var(--dark);
    --red: 37;
    --green: 211;
    --blue: 102;
    --dark:rgb( calc( var(--red) - 75),calc( var(--green) - 75),calc( var(--blue) - 75));
}

Gives the following output after parsing:

[
    {
        "tokens": [
            [
                {
                    ".dark": {
                        "1": [
                            "dark"
                        ]
                    }
                },
                [
                    "background:var(--dark)",
                    "--red:37",
                    "--green:211",
                    "--blue:102"
                ]
            ]
        ]
    }
]

As you can see, the --dark:rgb( calc( var(--red) - 75),calc( var(--green) - 75),calc( var(--blue) - 75)); is removed.

We isolated this to the calc() by using different values for rgb, like using only the variables, or using hardcoded values directly. In both cases, the output was correct.

This may be a duplicate of #257 which may be fixed in master.

I didn't state this in the OP, but testing of this issue was done with the master branch.

ezoic increase your site revenue