Skip to content

Commit

Permalink
allow for all properties with an empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
cuth committed Jun 25, 2015
1 parent dd7de31 commit 0496fb1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Default:

- `root_value` (Number) The root element font size.
- `unit_precision` (Number) The decimal numbers to allow the REM units to grow to.
- `prop_white_list` (Array) The properties that can change from px to rem.
- `prop_white_list` (Array) The properties that can change from px to rem. Set this to an empty array to disable the white list and enable all properties.
- `selector_black_list` (Array) The selectors to ignore and leave as px.
- `replace` (Boolean) replaces rules containing rems instead of adding fallbacks.
- `media_query` (Boolean) Allow px to be converted in media queries.
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = postcss.plugin('postcss-pxtorem', function (options) {
};

css.eachDecl(function (decl, i) {
if (propWhiteList.indexOf(decl.prop) === -1) return;
if (propWhiteList.length && propWhiteList.indexOf(decl.prop) === -1) return;

if (blacklistedSelector(selectorBlackList, decl.parent.selector)) return;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "postcss-pxtorem",
"description": "A CSS post-processor that converts px to rem.",
"version": "2.2.0",
"version": "2.3.0",
"author": "cuth",
"license": "MIT",
"repository": {
Expand Down
11 changes: 11 additions & 0 deletions spec/pxtorem-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ describe('pxtorem', function () {
expect(processed).toBe(expected);
});

it('should replace all properties when white list is empty', function () {
var rules = '.rule { margin: 16px; font-size: 15px }';
var expected = '.rule { margin: 1rem; font-size: 0.9375rem }';
var options = {
prop_white_list: []
};
var processed = postcss(pxtorem(options)).process(rules).css;

expect(processed).toBe(expected);
});

it('should ignore selectors in the selector black list', function () {
var rules = '.rule { font-size: 15px } .rule2 { font-size: 15px }';
var expected = '.rule { font-size: 0.9375rem } .rule2 { font-size: 15px }';
Expand Down

0 comments on commit 0496fb1

Please sign in to comment.