GoScrobble/web/node_modules/postcss-flexbugs-fixes/bugs/bug6.js

17 lines
650 B
JavaScript
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
var postcss = require('postcss');
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 : '');
}
};