Skip to content

Commit

Permalink
Add option to disable bug fixes (#53)
Browse files Browse the repository at this point in the history
I really don't like that `bug6` removes `0%` because it breaks `flex: 1;` in IE (`bug4`).
So instead of rewriting `bug6` I added the possibility to disable bugs fixes.

Closes #13
  • Loading branch information
dertieran authored and luisrudge committed Jul 30, 2018
1 parent b5704e9 commit 45d8db1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -63,6 +63,12 @@
postcss([require('postcss-flexbugs-fixes')]);
```

You can also disable bugs individually, possible keys `bug4`, `bug6` and `bug8a`.
```js
var plugin = require('postcss-flexbugs-fixes');
postcss([plugin({ bug6: false })]);
```

See [PostCSS] docs for examples for your environment.

[postcss]: https://github.com/postcss/postcss
Expand Down
14 changes: 10 additions & 4 deletions index.js
Expand Up @@ -6,7 +6,7 @@ var bug81a = require('./bugs/bug81a');
var doNothingValues = ['none', 'auto', 'content', 'inherit', 'initial', 'unset'];

module.exports = postcss.plugin('postcss-flexbugs-fixes', function (opts) {
opts = opts || {};
var options = Object.assign({ bug4: true, bug6: true, bug81a: true }, opts);

return function (css) {
css.walkDecls(function (d) {
Expand All @@ -17,9 +17,15 @@ module.exports = postcss.plugin('postcss-flexbugs-fixes', function (opts) {
if (doNothingValues.indexOf(d.value) > 0 && values.length === 1) {
return;
}
bug4(d);
bug6(d);
bug81a(d);
if (options.bug4) {
bug4(d);
}
if (options.bug6) {
bug6(d);
}
if (options.bug81a) {
bug81a(d);
}
});
};
});
9 changes: 9 additions & 0 deletions specs/pluginSpec.js
@@ -0,0 +1,9 @@
var test = require('./test');

describe('plugin options', function() {
it('allows to disable bug fixes', function(done) {
var input = 'div{flex: 1;}';
var output = 'div{flex: 1;}';
test(input, output, { bug4: false, bug6: false, bug8a: false }, done);
});
});

0 comments on commit 45d8db1

Please sign in to comment.