File tree 2 files changed +11
-18
lines changed
2 files changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -13,3 +13,10 @@ export function isComponent(node) {
13
13
node . parent . type === 'root'
14
14
) ;
15
15
}
16
+
17
+ export function isVariant ( node ) {
18
+ return (
19
+ node . type === 'rule' &&
20
+ node . selector . charAt ( 0 ) === ':'
21
+ ) ;
22
+ }
Original file line number Diff line number Diff line change 3
3
* @flow
4
4
*/
5
5
6
+ import * as Syntax from './Syntax' ;
7
+
6
8
/**
7
9
* Variant names we want to see compiled as CSS pseudo classes.
8
10
*/
@@ -36,7 +38,7 @@ const _SUPPORTED_PSEUDO_CLASSES = {
36
38
export default function transformVariants ( root ) {
37
39
let toAppend = [ ] ;
38
40
root . each ( rule => {
39
- if ( isComponent ( rule ) ) {
41
+ if ( Syntax . isComponent ( rule ) ) {
40
42
toAppend = toAppend . concat ( flattenVariants ( rule ) ) ;
41
43
}
42
44
} ) ;
@@ -48,7 +50,7 @@ function flattenVariants(rule) {
48
50
let toRemove = [ ] ;
49
51
let toAppend = [ ] ;
50
52
rule . each ( variant => {
51
- if ( ! isVariant ( variant ) ) {
53
+ if ( ! Syntax . isVariant ( variant ) ) {
52
54
return ;
53
55
}
54
56
toRemove . push ( variant ) ;
@@ -59,19 +61,3 @@ function flattenVariants(rule) {
59
61
toRemove . forEach ( variant => variant . remove ( ) ) ;
60
62
return toAppend ;
61
63
}
62
-
63
- export function isVariant ( node ) {
64
- return (
65
- node . type === 'rule' &&
66
- node . selector . charAt ( 0 ) === ':'
67
- ) ;
68
- }
69
-
70
- export function isComponent ( node ) {
71
- return (
72
- node . type === 'rule' &&
73
- node . selector . charAt ( 0 ) !== ':' &&
74
- node . parent &&
75
- node . parent . type === 'root'
76
- ) ;
77
- }
You can’t perform that action at this time.
0 commit comments