Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
iegik committed Nov 6, 2018
1 parent 95327e0 commit 39b8bf3
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions bugs/bug6.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,32 @@ module.exports = function(decl) {
if (decl.prop === 'flex') {
var values = postcss.list.space(decl.value);
var flexGrow = values[0];
var flexShrink = values[1] || '1';
var flexBasis = values[2] || '0%';
// Safari seems to hate '0%' and the others seems to make do with a nice value when basis is missing,
// so if we see a '0%', just remove it. This way it'll get adjusted for any other cases where '0%' is
// already defined somewhere else.
if(flexBasis === '0%') flexBasis = null;
decl.value = flexGrow + ' ' + flexShrink + (flexBasis ? ' ' + flexBasis : '');
var flexShrink = values[1];
var flexBasis = values[2];
if (flexGrow){
var grow = postcss.decl({
prop: 'flex-grow',
value: flexGrow,
source: decl.source
});
decl.parent.insertBefore(decl, grow);
}
if (flexShrink){
var shrink = postcss.decl({
prop: 'flex-shrink',
value: flexShrink,
source: decl.source
});
decl.parent.insertBefore(decl, shrink);
}
if (flexBasis){
var grow = postcss.decl({
prop: 'flex-basis',
value: flexBasis,
source: decl.source
});
decl.parent.insertBefore(decl, basis);
}
decl.remove();
}
};

0 comments on commit 39b8bf3

Please sign in to comment.