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

Bug on "CompressUnitValues" #62

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
.name {background-position: 0px 0px ;}

when "CompressUnitValues" is true , these content will be convert to : ".name 
{background-position: 0 ;}"

What version of CssMin are you using (source and/or build)?
Build of Version 3.0.1

What is the expected result?
.name {background-position: 0 0;}

Original issue reported on code.google.com by colinv...@gmail.com on 15 Nov 2012 at 6:14

GoogleCodeExporter commented 8 years ago
line 3643   "/(^0\s0\s0\s0)|(^0\s0\s0$)|(^0\s0$)/iS" => "0"

just remove this line , it will be OK .

Original comment by colinv...@gmail.com on 15 Nov 2012 at 6:29

GoogleCodeExporter commented 8 years ago
Another solution is to replace the apply function in the 
CssCompressUnitValuesMinifierPlugin with

/**
 * Skip these properties processing
 * @var array
 */
protected $propertiesToSkip = array
    (
    'background-position',
    'background'
    );
/**
 * Implements {@link aCssMinifierPlugin::minify()}.
 * 
 * @param aCssToken $token Token to process
 * @return boolean Return TRUE to break the processing of this token; FALSE to continue
 */
public function apply(aCssToken &$token)
{
    if (in_array(strtolower($token->Property), $this->propertiesToSkip)) return true;
    if (preg_match($this->reMatch, $token->Value))
        {
        foreach ($this->re as $reMatch => $reReplace)
            {
            $token->Value = preg_replace($reMatch, $reReplace, $token->Value);
            }
        }
    return false;
}

Original comment by daniel.r...@gmail.com on 15 Oct 2013 at 4:13