Skip to content
Permalink
Browse files

+ Implemented proper calc() support in Wess. Well, that was easier th…

…an expected... I thought I'd have forgotten how to write proper recursive regexes by now. (Class-CSS.php, Subs-Cache.php)
  • Loading branch information...
Nao committed May 11, 2019
1 parent 9fd7470 commit 294d044b4f19fac22cb1a36eb8beb5afc9c4e771
Showing with 5 additions and 5 deletions.
  1. +2 −1 core/app/Class-CSS.php
  2. +3 −4 core/app/Subs-Cache.php
@@ -1641,6 +1641,7 @@ private function fix_values($matches)
// IE9+/Firefox 16+/Chrome 27+ support this unprefixed, Safari 6 needs a prefix.
if (strpos($matches[1], 'calc') !== false)
{
$matches[1] = str_replace($matches[2], str_replace(' ', '#wedge-space#', $matches[2]), $matches[1]);
if (($b['ie'] && $v >= 9) || ($b['chrome'] && $v >= 27) || ($b['firefox'] && $v >= 16))
return $matches[1];
if (($b['chrome'] && $v >= 19) || ($b['firefox'] && $v >= 4) || ($b['safari'] && $v == 6) || ($os['ios'] && $ov >= 6 && $ov < 7))
@@ -1685,7 +1686,7 @@ function process(&$css)
'display:\h*(flex|inline-flex)\b', // Final flexbox model declarations
'\b(min|max)-resolution:\h*([\d.]+)(dppx|dpi)', // Useful for responsive design
'\brect\h*\(([^)]+)\)', // rect() function, needs commas except in IE 6/7
'\bcalc\h*\(', // calc() function
'\bcalc\h*\(((?>[^(]|\((?!\))|(?R))+?)\)', // calc() function
];
foreach ($values as $val)
@@ -725,8 +725,7 @@ function wedge_cache_css_files($folder, $ids, $latest_date, $css, $gzip = false,
// Remove the 'final' keyword.
$final = preg_replace('~\s+final\b~', '', $final);
// Remove extra whitespace. Note that this breaks additions and substractions in calc(), as they need their own whitespace.
// I'll be fixing this, eventually. But needs more regexes, more CPU time, and this means more kitties getting slaughtered. :(
// Remove extra whitespace.
$final = preg_replace('~\s\[~', '#wedge-bracket#', $final);
$final = preg_replace('~\s*([][+:;,>{}\s])\s*~', '$1', $final);
$final = str_replace('#wedge-bracket#', ' [', $final);
@@ -738,8 +737,8 @@ function wedge_cache_css_files($folder, $ids, $latest_date, $css, $gzip = false,
// Remove double quote hacks, remaining whitespace, and no-base64 tricks.
$final = str_replace(
['#wedge-quote#', "\n\n", ';;', ';}', "}\n", "\t", ' !important', 'raw-url('],
['"', "\n", ';', '}', '}', ' ', '!important', 'url('],
['#wedge-quote#', '#wedge-space#', "\n\n", ';;', ';}', "}\n", "\t", ' !important', 'raw-url('],
['"', ' ', "\n", ';', '}', '}', ' ', '!important', 'url('],
$final
);

0 comments on commit 294d044

Please sign in to comment.
You can’t perform that action at this time.