arbk / cssmin

CssMin - A (simple) css minifier with benefits. (exported from Google Code)
http://code.google.com/p/cssmin/
1 stars 1 forks source link

@-webkit-keyframes parsing/minifying bug #41

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What version of CssMin are you using (source and/or build)?
3

What was the input stylesheet and/or configuration options?
default

What is the expected result?
if the last declaration in a css string is a @-webkit-keyframes declaration, 
the last "}" is omitted from the output:

@-webkit-keyframes bounce_circle 
{
    0% 
    {
        opacity:0.3;
    }
    50% 
    {
        opacity:1;
        background-color:#111
    }
    100% 
    {
        opacity:0.3;
    }
}

And what is the actual result and/or error message?

@-webkit-keyframes bounce_circle{0% {
opacity:0.3}50%{opacity:1;background-color:#111}100%{opacity:0.3}

Please provide any additional information below.

As you can see that last "}" is left out.  This only occurs if that is the last 
declaration in the css string.  if there is another declaration after that, 
everything looks fine.

Original issue reported on code.google.com by vdudukg...@gmail.com on 18 Aug 2011 at 7:11

GoogleCodeExporter commented 8 years ago
Thanks for reporting this bug.

Original comment by joe.scylla on 18 Aug 2011 at 10:04

GoogleCodeExporter commented 8 years ago
The problem results because the @-webkit-keyframes did not get parsed by the 
parser plugin responsible for parsing @keyframes at-rule blocks. This parser 
plugin triggers only on the keyword "@keyframes" (and not on 
"@-webkit-keyframes").

A temporary fix would be to use the keyword "@keyframes" and activate the 
minifier filter "ConvertLevel3AtKeyframes".

See: http://code.google.com/p/cssmin/wiki/MinifierFilterConvertLevel3AtKeyframes

Original comment by joe.scylla on 18 Aug 2011 at 10:41

GoogleCodeExporter commented 8 years ago
Unfortunately I don't have control over the CSS that I'm dealing with.  I tried 
changing some code in the CssAtKeyframesParserPlugin class in the parse method 
to detect the webkit declaration.  The issue was that it would parse correctly 
but change to @keyframes instead of @-webkit-keyfrmaes:

        if ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 10)) === "@keyframes")
            {
            $this->parser->pushState("T_AT_KEYFRAMES::NAME");
            $this->parser->clearBuffer();
            return $index + 10;
            }
                // Start of @keyframes at-rule block
        elseif ($char === "@" && $state === "T_DOCUMENT" && strtolower(substr($this->parser->getSource(), $index, 18)) === "@-webkit-keyframes")
            {
            $this->parser->pushState("T_AT_KEYFRAMES::NAME");
            $this->parser->clearBuffer();
            return $index + 10;
            }

Original comment by vdudukg...@gmail.com on 18 Aug 2011 at 2:46

GoogleCodeExporter commented 8 years ago
Fixed in Version 3.0.1 (Revision #163)

See: http://code.google.com/p/cssmin/wiki/WhatsNewVersion301

Original comment by joe.scylla on 19 Aug 2011 at 10:25