Skip to content

Commit 0496fb1

Browse files
committed
allow for all properties with an empty array
1 parent dd7de31 commit 0496fb1

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Default:
4545

4646
- `root_value` (Number) The root element font size.
4747
- `unit_precision` (Number) The decimal numbers to allow the REM units to grow to.
48-
- `prop_white_list` (Array) The properties that can change from px to rem.
48+
- `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.
4949
- `selector_black_list` (Array) The selectors to ignore and leave as px.
5050
- `replace` (Boolean) replaces rules containing rems instead of adding fallbacks.
5151
- `media_query` (Boolean) Allow px to be converted in media queries.

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = postcss.plugin('postcss-pxtorem', function (options) {
2121
};
2222

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

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "postcss-pxtorem",
33
"description": "A CSS post-processor that converts px to rem.",
4-
"version": "2.2.0",
4+
"version": "2.3.0",
55
"author": "cuth",
66
"license": "MIT",
77
"repository": {

spec/pxtorem-spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ describe('pxtorem', function () {
4949
expect(processed).toBe(expected);
5050
});
5151

52+
it('should replace all properties when white list is empty', function () {
53+
var rules = '.rule { margin: 16px; font-size: 15px }';
54+
var expected = '.rule { margin: 1rem; font-size: 0.9375rem }';
55+
var options = {
56+
prop_white_list: []
57+
};
58+
var processed = postcss(pxtorem(options)).process(rules).css;
59+
60+
expect(processed).toBe(expected);
61+
});
62+
5263
it('should ignore selectors in the selector black list', function () {
5364
var rules = '.rule { font-size: 15px } .rule2 { font-size: 15px }';
5465
var expected = '.rule { font-size: 0.9375rem } .rule2 { font-size: 15px }';

0 commit comments

Comments
 (0)