File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed
packages/container-query-meta-builder/src Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change 1
- import { trim } from "lodash" ;
2
-
3
1
/**
4
2
* Extracts conditions as arrays from a single "param" string PostCSS provides
5
3
* for at-rules.
@@ -11,18 +9,15 @@ import { trim } from "lodash";
11
9
export default function getConditionsFromQueryParams ( params ) {
12
10
return params . split ( "," ) . map ( andParams => {
13
11
return andParams . match ( / \( ( [ ^ \) ] * ) \) / g) . map ( condition => {
14
- let conditionArr = trim ( condition , "()" ) ;
15
-
16
- conditionArr = conditionArr . match ( / ( [ a - z - ] * ) ( [ : > < = ] * ) ( [ a - z 0 - 9 \. ] * ) / i) ;
17
- conditionArr . shift ( ) ;
18
-
19
- conditionArr = conditionArr . map ( trim ) ;
12
+ const conditionArr = condition . match (
13
+ / \( ( [ a - z - ] * ) * ( [: > <= ] * ) * ( [ a - z 0 - 9 \. ] * ) \) / i
14
+ ) ;
20
15
21
- if ( [ "landscape" , "portrait" ] . indexOf ( conditionArr [ 2 ] ) === - 1 ) {
22
- conditionArr [ 2 ] = parseFloat ( conditionArr [ 2 ] ) ;
16
+ if ( [ "landscape" , "portrait" ] . indexOf ( conditionArr [ 3 ] ) === - 1 ) {
17
+ conditionArr [ 3 ] = parseFloat ( conditionArr [ 3 ] ) ;
23
18
}
24
19
25
- return conditionArr ;
20
+ return conditionArr . slice ( 1 ) ;
26
21
} ) ;
27
22
} ) ;
28
23
}
You can’t perform that action at this time.
0 commit comments