Skip to content

Commit

Permalink
Merge pull request #22 from silvenon/basis
Browse files Browse the repository at this point in the history
The default value of flex-basis is 0%
  • Loading branch information
luisrudge committed Sep 12, 2015
2 parents 33eeeda + b45258e commit 89ebf48
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
6 changes: 3 additions & 3 deletions bugs/bug4.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ module.exports = function(decl) {
}
var values = postcss.list.space(decl.value);
var flexGrow = values[0];
var flexShrink = values[1];
var flexBasis = values[2] || 'auto';
decl.value = flexGrow + ' ' + (flexShrink || '1') + ' ' + properBasis(flexBasis);
var flexShrink = values[1] || '1';
var flexBasis = values[2] || '0%';
decl.value = flexGrow + ' ' + flexShrink + ' ' + properBasis(flexBasis);
}
};
7 changes: 7 additions & 0 deletions bugs/bug6.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
var postcss = require('postcss');

module.exports = function(decl) {
if (decl.prop === 'flex') {
if(decl.value === 'none'){
return;
}
var values = postcss.list.space(decl.value);
var flexGrow = values[0];
var flexShrink = values[1] || '1';
var flexBasis = values[2] || '0%';
decl.value = flexGrow + ' ' + flexShrink + ' ' + flexBasis;
}
};
8 changes: 4 additions & 4 deletions specs/bug4Spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var test = require('./test');

describe('bug 4', function() {
it('set auto for default flex-basis and 1 for flex-shrink in flex shorthand', function(done) {
it('set 0% for default flex-basis and 1 for flex-shrink in flex shorthand', function(done) {
var input = 'div{flex: 1;}';
var output = 'div{flex: 1 1 auto;}';
var output = 'div{flex: 1 1 0%;}';
test(input, output, {}, done);
});
it('set auto for default flex-basis when not specified', function(done) {
it('set 0% for default flex-basis when not specified', function(done) {
var input = 'div{flex: 1 1;}';
var output = 'div{flex: 1 1 auto;}';
var output = 'div{flex: 1 1 0%;}';
test(input, output, {}, done);
});
it('set flex-basis === 0% for flex-basis with plain 0', function(done) {
Expand Down
2 changes: 1 addition & 1 deletion specs/bug6Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var test = require('./test');
describe('bug 6', function() {
it('Set flex-shrink to 1 by default', function(done) {
var input = 'div{flex: 1;}';
var output = 'div{flex: 1 1 auto;}';
var output = 'div{flex: 1 1 0%;}';
test(input, output, {}, done);
});
describe('does nothing', function() {
Expand Down
4 changes: 2 additions & 2 deletions specs/bug81aSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ describe('bug 8.1.a', function() {
describe('does nothing', function() {
it('when using only first value', function(done) {
var input = 'a{flex: 0}';
var output = 'a{flex: 0 1 auto}';
var output = 'a{flex: 0 1 0%}';
test(input, output, {}, done);
});
it('when using only first and second values', function(done) {
var input = 'a{flex: 0 0}';
var output = 'a{flex: 0 0 auto}';
var output = 'a{flex: 0 0 0%}';
test(input, output, {}, done);
});
it('when not using calc', function(done) {
Expand Down

0 comments on commit 89ebf48

Please sign in to comment.