@@ -6,12 +6,20 @@ const defaults = {
66 rootValue : 16 ,
77 unitPrecision : 5 ,
88 selectorBlackList : [ ] ,
9- propList : [ "font" , "font-size" , "line-height" , "letter-spacing" , "word-spacing" ] ,
9+ propList : [
10+ "font" ,
11+ "font-size" ,
12+ "line-height" ,
13+ "letter-spacing" ,
14+ "word-spacing"
15+ ] ,
1016 replace : true ,
1117 mediaQuery : false ,
18+ containerQuery : false ,
19+ supportsQuery : false ,
1220 minPixelValue : 0 ,
1321 exclude : null ,
14- unit : "px" ,
22+ unit : "px"
1523} ;
1624
1725const legacyOptions = {
@@ -20,7 +28,7 @@ const legacyOptions = {
2028 selector_black_list : "selectorBlackList" ,
2129 prop_white_list : "propList" ,
2230 media_query : "mediaQuery" ,
23- propWhiteList : "propList" ,
31+ propWhiteList : "propList"
2432} ;
2533
2634function convertLegacyOptions ( options ) {
@@ -36,7 +44,7 @@ function convertLegacyOptions(options) {
3644 delete options [ "prop_white_list" ] ;
3745 delete options . propWhiteList ;
3846 }
39- Object . keys ( legacyOptions ) . forEach ( ( key ) => {
47+ Object . keys ( legacyOptions ) . forEach ( key => {
4048 if ( Reflect . has ( options , key ) ) {
4149 options [ legacyOptions [ key ] ] = options [ key ] ;
4250 delete options [ key ] ;
@@ -61,12 +69,12 @@ function toFixed(number, precision) {
6169}
6270
6371function declarationExists ( decls , prop , value ) {
64- return decls . some ( ( decl ) => decl . prop === prop && decl . value === value ) ;
72+ return decls . some ( decl => decl . prop === prop && decl . value === value ) ;
6573}
6674
6775function blacklistedSelector ( blacklist , selector ) {
6876 if ( typeof selector !== "string" ) return ;
69- return blacklist . some ( ( regex ) => {
77+ return blacklist . some ( regex => {
7078 if ( typeof regex === "string" ) {
7179 return selector . indexOf ( regex ) !== - 1 ;
7280 }
@@ -85,31 +93,31 @@ function createPropListMatcher(propList) {
8593 notExact : filterPropList . notExact ( propList ) ,
8694 notContain : filterPropList . notContain ( propList ) ,
8795 notStartWith : filterPropList . notStartWith ( propList ) ,
88- notEndWith : filterPropList . notEndWith ( propList ) ,
96+ notEndWith : filterPropList . notEndWith ( propList )
8997 } ;
90- return ( prop ) => {
98+ return prop => {
9199 if ( matchAll ) return true ;
92100 return (
93101 ( hasWild ||
94102 lists . exact . indexOf ( prop ) > - 1 ||
95- lists . contain . some ( function ( m ) {
103+ lists . contain . some ( function ( m ) {
96104 return prop . indexOf ( m ) > - 1 ;
97105 } ) ||
98- lists . startWith . some ( function ( m ) {
106+ lists . startWith . some ( function ( m ) {
99107 return prop . indexOf ( m ) === 0 ;
100108 } ) ||
101- lists . endWith . some ( function ( m ) {
109+ lists . endWith . some ( function ( m ) {
102110 return prop . indexOf ( m ) === prop . length - m . length ;
103111 } ) ) &&
104112 ! (
105113 lists . notExact . indexOf ( prop ) > - 1 ||
106- lists . notContain . some ( function ( m ) {
114+ lists . notContain . some ( function ( m ) {
107115 return prop . indexOf ( m ) > - 1 ;
108116 } ) ||
109- lists . notStartWith . some ( function ( m ) {
117+ lists . notStartWith . some ( function ( m ) {
110118 return prop . indexOf ( m ) === 0 ;
111119 } ) ||
112- lists . notEndWith . some ( function ( m ) {
120+ lists . notEndWith . some ( function ( m ) {
113121 return prop . indexOf ( m ) === prop . length - m . length ;
114122 } )
115123 )
@@ -146,7 +154,7 @@ module.exports = (options = {}) => {
146154 pxReplace = createPxReplace (
147155 rootValue ,
148156 opts . unitPrecision ,
149- opts . minPixelValue ,
157+ opts . minPixelValue
150158 ) ;
151159 } ,
152160 Declaration ( decl ) {
@@ -177,7 +185,17 @@ module.exports = (options = {}) => {
177185 if ( atRule . params . indexOf ( opts . unit ) === - 1 ) return ;
178186 atRule . params = atRule . params . replace ( pxRegex ( opts . unit ) , pxReplace ) ;
179187 }
180- } ,
188+
189+ if ( opts . containerQuery && atRule . name === "container" ) {
190+ if ( atRule . params . indexOf ( opts . unit ) === - 1 ) return ;
191+ atRule . params = atRule . params . replace ( pxRegex ( opts . unit ) , pxReplace ) ;
192+ }
193+
194+ if ( opts . supportsQuery && atRule . name === "supports" ) {
195+ if ( atRule . params . indexOf ( opts . unit ) === - 1 ) return ;
196+ atRule . params = atRule . params . replace ( pxRegex ( opts . unit ) , pxReplace ) ;
197+ }
198+ }
181199 } ;
182200} ;
183201module . exports . postcss = true ;
0 commit comments