Skip to content

Commit

Permalink
Fix unitless flex-basis, for IE
Browse files Browse the repository at this point in the history
Fixes #159
  • Loading branch information
matthiasmullie committed Jan 26, 2017
1 parent 49061c0 commit aa50b2d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/CSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,12 @@ protected function shortenZeroes($content)
// respected etc)
// what I cared about most here was fixing incorrectly truncated units

// IE doesn't seem to understand a unitless flex-basis value, so let's
// add it in again (make it `%`, which is only 1 char: 0%, 0px, 0
// anything, it's all just the same)
$content = preg_replace('/flex:([^ ]+ [^ ]+ )0([;\}])/', 'flex:${1}0%${2}', $content);
$content = preg_replace('/flex-basis:0([;\}])/', 'flex-basis:0%${1}', $content);

return $content;
}

Expand Down
19 changes: 19 additions & 0 deletions tests/css/CSSTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,25 @@ public function dataProvider()
'.text{box-shadow:0 0 1em -.5em #000}',
);

// https://github.com/matthiasmullie/minify/issues/159
$tests[] = array(
'.columns {
-webkit-flex: 1 1 0px;
-ms-flex: 1 1 0px;
flex: 1 1 0px;
min-width: 0;
}',
'.columns{-webkit-flex:1 1 0%;-ms-flex:1 1 0%;flex:1 1 0%;min-width:0}',
);
$tests[] = array(
'html{height:100%;font-family:sans-serif}.grid{max-width:60em;display:-webkit-box;display:-ms-flexbox;display:flex;margin:0 auto;-ms-flex-wrap:wrap;flex-wrap:wrap}.column{margin:.5em;-webkit-box-flex:1;-ms-flex:1 1 0px;flex:1 1 0px;border:1px solid #333;height:1em;padding:1em;text-align:center;color:#333}',
'html{height:100%;font-family:sans-serif}.grid{max-width:60em;display:-webkit-box;display:-ms-flexbox;display:flex;margin:0 auto;-ms-flex-wrap:wrap;flex-wrap:wrap}.column{margin:.5em;-webkit-box-flex:1;-ms-flex:1 1 0%;flex:1 1 0%;border:1px solid #333;height:1em;padding:1em;text-align:center;color:#333}',
);
$tests[] = array(
'p{flex:1 1 0;-ms-flex-basis:0%;}',
'p{flex:1 1 0%;-ms-flex-basis:0%}',
);

return $tests;
}

Expand Down

0 comments on commit aa50b2d

Please sign in to comment.