@@ -5,7 +5,7 @@ describe("Parse CSS", () => {
5
5
test ( "longhand property name with keyword value" , ( ) => {
6
6
expect ( parseCss ( `.test { background-color: red }` ) ) . toEqual ( [
7
7
{
8
- selector : "test" ,
8
+ selector : ". test" ,
9
9
property : "backgroundColor" ,
10
10
value : { type : "keyword" , value : "red" } ,
11
11
} ,
@@ -15,7 +15,7 @@ describe("Parse CSS", () => {
15
15
test ( "one class selector rules" , ( ) => {
16
16
expect ( parseCss ( `.test { color: #ff0000 }` ) ) . toEqual ( [
17
17
{
18
- selector : "test" ,
18
+ selector : ". test" ,
19
19
property : "color" ,
20
20
value : { alpha : 1 , b : 0 , g : 0 , r : 255 , type : "rgb" } ,
21
21
} ,
@@ -30,7 +30,7 @@ describe("Parse CSS", () => {
30
30
` ;
31
31
expect ( parseCss ( css ) ) . toEqual ( [
32
32
{
33
- selector : "test" ,
33
+ selector : ". test" ,
34
34
property : "backgroundImage" ,
35
35
value : {
36
36
type : "layers" ,
@@ -45,7 +45,7 @@ describe("Parse CSS", () => {
45
45
} ,
46
46
} ,
47
47
{
48
- selector : "test" ,
48
+ selector : ". test" ,
49
49
property : "backgroundPositionX" ,
50
50
value : {
51
51
type : "layers" ,
@@ -56,7 +56,7 @@ describe("Parse CSS", () => {
56
56
} ,
57
57
} ,
58
58
{
59
- selector : "test" ,
59
+ selector : ". test" ,
60
60
property : "backgroundPositionY" ,
61
61
value : {
62
62
type : "layers" ,
@@ -67,7 +67,7 @@ describe("Parse CSS", () => {
67
67
} ,
68
68
} ,
69
69
{
70
- selector : "test" ,
70
+ selector : ". test" ,
71
71
property : "backgroundSize" ,
72
72
value : {
73
73
type : "layers" ,
@@ -90,7 +90,7 @@ describe("Parse CSS", () => {
90
90
} ,
91
91
} ,
92
92
{
93
- selector : "test" ,
93
+ selector : ". test" ,
94
94
property : "backgroundRepeat" ,
95
95
value : {
96
96
type : "layers" ,
@@ -101,7 +101,7 @@ describe("Parse CSS", () => {
101
101
} ,
102
102
} ,
103
103
{
104
- selector : "test" ,
104
+ selector : ". test" ,
105
105
property : "backgroundAttachment" ,
106
106
value : {
107
107
type : "layers" ,
@@ -112,7 +112,7 @@ describe("Parse CSS", () => {
112
112
} ,
113
113
} ,
114
114
{
115
- selector : "test" ,
115
+ selector : ". test" ,
116
116
property : "backgroundOrigin" ,
117
117
value : {
118
118
type : "layers" ,
@@ -123,7 +123,7 @@ describe("Parse CSS", () => {
123
123
} ,
124
124
} ,
125
125
{
126
- selector : "test" ,
126
+ selector : ". test" ,
127
127
property : "backgroundClip" ,
128
128
value : {
129
129
type : "layers" ,
@@ -134,7 +134,7 @@ describe("Parse CSS", () => {
134
134
} ,
135
135
} ,
136
136
{
137
- selector : "test" ,
137
+ selector : ". test" ,
138
138
property : "backgroundColor" ,
139
139
value : { alpha : 1 , b : 252 , g : 255 , r : 235 , type : "rgb" } ,
140
140
} ,
@@ -149,31 +149,31 @@ describe("Parse CSS", () => {
149
149
` ;
150
150
expect ( parseCss ( css ) ) . toEqual ( [
151
151
{
152
- selector : "test" ,
152
+ selector : ". test" ,
153
153
property : "backgroundImage" ,
154
154
value : {
155
155
type : "layers" ,
156
156
value : [ { type : "keyword" , value : "none" } ] ,
157
157
} ,
158
158
} ,
159
159
{
160
- selector : "test" ,
160
+ selector : ". test" ,
161
161
property : "backgroundPositionX" ,
162
162
value : {
163
163
type : "layers" ,
164
164
value : [ { type : "unit" , unit : "px" , value : 0 } ] ,
165
165
} ,
166
166
} ,
167
167
{
168
- selector : "test" ,
168
+ selector : ". test" ,
169
169
property : "backgroundPositionY" ,
170
170
value : {
171
171
type : "layers" ,
172
172
value : [ { type : "unit" , unit : "px" , value : 0 } ] ,
173
173
} ,
174
174
} ,
175
175
{
176
- selector : "test" ,
176
+ selector : ". test" ,
177
177
property : "backgroundSize" ,
178
178
value : {
179
179
type : "layers" ,
@@ -194,7 +194,18 @@ describe("Parse CSS", () => {
194
194
] ) ;
195
195
} ) ;
196
196
197
+ test ( "attribute selector" , ( ) => {
198
+ expect ( parseCss ( `[class^="a"] { color: #ff0000 }` ) ) . toEqual ( [
199
+ {
200
+ selector : '[class^="a"]' ,
201
+ property : "color" ,
202
+ value : { alpha : 1 , b : 0 , g : 0 , r : 255 , type : "rgb" } ,
203
+ } ,
204
+ ] ) ;
205
+ } ) ;
206
+
197
207
test ( "parse first pseudo class as selector" , ( ) => {
208
+ // E.g. :root
198
209
expect ( parseCss ( `:first-pseudo:my-state { color: #ff0000 }` ) ) . toEqual ( [
199
210
{
200
211
selector : ":first-pseudo" ,
@@ -471,11 +482,33 @@ describe("Parse CSS", () => {
471
482
} ) ;
472
483
473
484
test ( "parse child combinator" , ( ) => {
474
- expect ( parseCss ( `a > b { color: #ff0000 }` ) ) . toEqual ( [ ] ) ;
485
+ expect ( parseCss ( `a > b { color: #ff0000 }` ) ) . toEqual ( [
486
+ {
487
+ selector : "a > b" ,
488
+ property : "color" ,
489
+ value : { alpha : 1 , b : 0 , g : 0 , r : 255 , type : "rgb" } ,
490
+ } ,
491
+ ] ) ;
475
492
} ) ;
476
493
477
494
test ( "parse space combinator" , ( ) => {
478
- expect ( parseCss ( `a b { color: #ff0000 }` ) ) . toEqual ( [ ] ) ;
495
+ expect ( parseCss ( `.a b { color: #ff0000 }` ) ) . toEqual ( [
496
+ {
497
+ selector : ".a b" ,
498
+ property : "color" ,
499
+ value : { alpha : 1 , b : 0 , g : 0 , r : 255 , type : "rgb" } ,
500
+ } ,
501
+ ] ) ;
502
+ } ) ;
503
+
504
+ test ( "parse nested selectors as one token" , ( ) => {
505
+ expect ( parseCss ( `a b c.d { color: #ff0000 }` ) ) . toEqual ( [
506
+ {
507
+ selector : "a b c.d" ,
508
+ property : "color" ,
509
+ value : { alpha : 1 , b : 0 , g : 0 , r : 255 , type : "rgb" } ,
510
+ } ,
511
+ ] ) ;
479
512
} ) ;
480
513
} ) ;
481
514
0 commit comments