File tree Expand file tree Collapse file tree 2 files changed +32
-14
lines changed Expand file tree Collapse file tree 2 files changed +32
-14
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ tape("cssnext browsers option", function(t) {
40
40
t . end ( )
41
41
} )
42
42
43
- tape ( "cssnext browsers option propagation" , function ( t ) {
43
+ tape ( "cssnext browsers option propagation to autoprefixer " , function ( t ) {
44
44
const input = "body{transition: 1s}"
45
45
const output = "body{-webkit-transition: 1s;transition: 1s}"
46
46
@@ -60,3 +60,17 @@ tape("cssnext browsers option propagation", function(t) {
60
60
61
61
t . end ( )
62
62
} )
63
+
64
+ tape ( "cssnext browsers option propagation to pixrem" , function ( t ) {
65
+ const input = "body{font-size: 1rem}"
66
+ const output = "body{font-size: 16px;font-size: 1rem}"
67
+
68
+ // IE 8 needs rem fallback
69
+ t . equal (
70
+ cssnext ( { browsers : "ie 8" } ) . process ( input ) . css ,
71
+ output ,
72
+ "should propagate browsers option to pixrem"
73
+ )
74
+
75
+ t . end ( )
76
+ } )
Original file line number Diff line number Diff line change @@ -14,21 +14,25 @@ const plugin = postcss.plugin("postcss-cssnext", (options) => {
14
14
15
15
const features = options . features
16
16
17
- // propagate browsers option to autoprefixer
18
- if ( features . autoprefixer !== false ) {
19
- features . autoprefixer = {
20
- browsers : (
21
- features . autoprefixer && features . autoprefixer . browsers
22
- ? features . autoprefixer . browsers
23
- : options . browsers
24
- ) ,
25
- ...( features . autoprefixer || { } ) ,
26
- }
17
+ // propagate browsers option to plugins that supports it
18
+ "autoprefixer pixrem" . split ( / \s / ) . forEach ( name => {
19
+ const feature = features [ name ]
27
20
28
- // autoprefixer doesn't like an "undefined" value. Related to coffee ?
29
- if ( features . autoprefixer . browsers === undefined ) {
30
- delete features . autoprefixer . browsers
21
+ if ( feature !== false ) {
22
+ features [ name ] = {
23
+ browsers : (
24
+ feature && feature . browsers
25
+ ? feature . browsers
26
+ : options . browsers
27
+ ) ,
28
+ ...( feature || { } ) ,
29
+ }
31
30
}
31
+ } )
32
+
33
+ // autoprefixer doesn't like an "undefined" value. Related to coffee ?
34
+ if ( features . autoprefixer && features . autoprefixer . browsers === undefined ) {
35
+ delete features . autoprefixer . browsers
32
36
}
33
37
34
38
const processor = postcss ( )
You can’t perform that action at this time.
0 commit comments