This repository was archived by the owner on Dec 19, 2024. It is now read-only.
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) {
4040 t . end ( )
4141} )
4242
43- tape ( "cssnext browsers option propagation" , function ( t ) {
43+ tape ( "cssnext browsers option propagation to autoprefixer " , function ( t ) {
4444 const input = "body{transition: 1s}"
4545 const output = "body{-webkit-transition: 1s;transition: 1s}"
4646
@@ -60,3 +60,17 @@ tape("cssnext browsers option propagation", function(t) {
6060
6161 t . end ( )
6262} )
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) => {
1414
1515 const features = options . features
1616
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 ]
2720
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+ }
3130 }
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
3236 }
3337
3438 const processor = postcss ( )
You can’t perform that action at this time.
0 commit comments