Combines multiply defined rule sets by merging the selectors in comma seperated format
Parameters
(array) selectors: Array of selectors broken down by setup:
(array) details: Array of rule sets broken down by setup:
1 call to CSSCompression_Organize::reduceDetails()
- CSSCompression_Organize::organize in advagg_css_compress/
css-compressor-3.x/ src/ lib/ Organize.inc - Look to see if we can combine selectors to reduce the number of definitions.
File
-
advagg_css_compress/
css-compressor-3.x/ src/ lib/ Organize.inc, line 104
Class
- CSSCompression_Organize
- CSS Compressor [VERSION] [DATE] Corey Hart @ http://www.codenothing.com
Code
private function reduceDetails($selectors, $details) {
$keys = array_keys($selectors);
$max = array_pop($keys) + 1;
for ($i = 0; $i < $max; $i++) {
if (!isset($selectors[$i])) {
continue;
}
$arr = preg_split($this->rsemicolon, isset($details[$i]) ? $details[$i] : '');
for ($k = $i + 1; $k < $max; $k++) {
if (!isset($selectors[$k])) {
continue;
}
$match = preg_split($this->rsemicolon, isset($details[$k]) ? $details[$k] : '');
$x = array_diff($arr, $match);
$y = array_diff($match, $arr);
if (count($x) < 1 && count($y) < 1) {
$selectors[$i] .= ',' . $selectors[$k];
unset($details[$k], $selectors[$k]);
}
}
}
return array(
$selectors,
$details,
);
}