Skip to content

Commit

Permalink
Revert "Revert Autoremoval of 0% Basis (#43)"
Browse files Browse the repository at this point in the history
This reverts commit fe6215e.
  • Loading branch information
luisrudge committed Apr 28, 2018
1 parent ae25569 commit 89c1265
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions bugs/bug6.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ module.exports = function(decl) {
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 : '');
}
};
10 changes: 5 additions & 5 deletions specs/bug4Spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ var test = require('./test');
describe('bug 4', function() {
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 0%;}';
var output = 'div{flex: 1 1;}';
test(input, output, {}, 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 0%;}';
var output = 'div{flex: 1 1;}';
test(input, output, {}, 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 0%;}';
var output = 'div{flex: 1 1;}';
test(input, output, {}, done);
});
it('set flex-basis === 0% for flex-basis with plain 0', function(done) {
var input = 'div{flex: 1 0 0;}';
var output = 'div{flex: 1 0 0%;}';
var output = 'div{flex: 1 0;}';
test(input, output, {}, done);
});
it('set flex-basis === 0% for flex-basis with 0px', function(done) {
var input = 'div{flex: 1 0 0px;}';
var output = 'div{flex: 1 0 0%;}';
var output = 'div{flex: 1 0;}';
test(input, output, {}, done);
});
it('set flex-basis when second value is not a number', function(done) {
Expand Down
6 changes: 3 additions & 3 deletions 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 0%;}';
var output = 'div{flex: 1 1;}';
test(input, output, {}, done);
});
describe('does nothing', function() {
Expand All @@ -17,12 +17,12 @@ describe('bug 6', function() {
});
it('when flex-shrink is set explicitly to zero', function(done) {
var css = 'div{flex: 1 0 0%;}';
var output = 'div{flex: 1 0 0%;}';
var output = 'div{flex: 1 0;}';
test(css, output, {}, done);
});
it('when flex-shrink is set explicitly to non-zero value', function(done) {
var css = 'div{flex: 1 2 0%}';
var output = 'div{flex: 1 2 0%}';
var output = 'div{flex: 1 2}';
test(css, output, {}, done);
});
describe('when flex value is reserved word', 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 0%}';
var output = 'a{flex: 0 1}';
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 0%}';
var output = 'a{flex: 0 0}';
test(input, output, {}, done);
});
it('when not using calc', function(done) {
Expand Down

0 comments on commit 89c1265

Please sign in to comment.