Skip to content

Commit b45258e

Browse files
committed
The default value of flex-basis is 0%
The INITIAL value is `auto`, silly me.
1 parent 33eeeda commit b45258e

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

bugs/bug4.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ module.exports = function(decl) {
2121
}
2222
var values = postcss.list.space(decl.value);
2323
var flexGrow = values[0];
24-
var flexShrink = values[1];
25-
var flexBasis = values[2] || 'auto';
26-
decl.value = flexGrow + ' ' + (flexShrink || '1') + ' ' + properBasis(flexBasis);
24+
var flexShrink = values[1] || '1';
25+
var flexBasis = values[2] || '0%';
26+
decl.value = flexGrow + ' ' + flexShrink + ' ' + properBasis(flexBasis);
2727
}
2828
};

bugs/bug6.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
var postcss = require('postcss');
2+
13
module.exports = function(decl) {
24
if (decl.prop === 'flex') {
35
if(decl.value === 'none'){
46
return;
57
}
8+
var values = postcss.list.space(decl.value);
9+
var flexGrow = values[0];
10+
var flexShrink = values[1] || '1';
11+
var flexBasis = values[2] || '0%';
12+
decl.value = flexGrow + ' ' + flexShrink + ' ' + flexBasis;
613
}
714
};

specs/bug4Spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
var test = require('./test');
22

33
describe('bug 4', function() {
4-
it('set auto for default flex-basis and 1 for flex-shrink in flex shorthand', function(done) {
4+
it('set 0% for default flex-basis and 1 for flex-shrink in flex shorthand', function(done) {
55
var input = 'div{flex: 1;}';
6-
var output = 'div{flex: 1 1 auto;}';
6+
var output = 'div{flex: 1 1 0%;}';
77
test(input, output, {}, done);
88
});
9-
it('set auto for default flex-basis when not specified', function(done) {
9+
it('set 0% for default flex-basis when not specified', function(done) {
1010
var input = 'div{flex: 1 1;}';
11-
var output = 'div{flex: 1 1 auto;}';
11+
var output = 'div{flex: 1 1 0%;}';
1212
test(input, output, {}, done);
1313
});
1414
it('set flex-basis === 0% for flex-basis with plain 0', function(done) {

specs/bug6Spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var test = require('./test');
33
describe('bug 6', function() {
44
it('Set flex-shrink to 1 by default', function(done) {
55
var input = 'div{flex: 1;}';
6-
var output = 'div{flex: 1 1 auto;}';
6+
var output = 'div{flex: 1 1 0%;}';
77
test(input, output, {}, done);
88
});
99
describe('does nothing', function() {

specs/bug81aSpec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ describe('bug 8.1.a', function() {
99
describe('does nothing', function() {
1010
it('when using only first value', function(done) {
1111
var input = 'a{flex: 0}';
12-
var output = 'a{flex: 0 1 auto}';
12+
var output = 'a{flex: 0 1 0%}';
1313
test(input, output, {}, done);
1414
});
1515
it('when using only first and second values', function(done) {
1616
var input = 'a{flex: 0 0}';
17-
var output = 'a{flex: 0 0 auto}';
17+
var output = 'a{flex: 0 0 0%}';
1818
test(input, output, {}, done);
1919
});
2020
it('when not using calc', function(done) {

0 commit comments

Comments
 (0)