@@ -5,7 +5,7 @@ describe("Parse CSS", () => {
55 test ( "longhand property name with keyword value" , ( ) => {
66 expect ( parseCss ( `.test { background-color: red }` ) ) . toEqual ( [
77 {
8- selector : "test" ,
8+ selector : ". test" ,
99 property : "backgroundColor" ,
1010 value : { type : "keyword" , value : "red" } ,
1111 } ,
@@ -15,7 +15,7 @@ describe("Parse CSS", () => {
1515 test ( "one class selector rules" , ( ) => {
1616 expect ( parseCss ( `.test { color: #ff0000 }` ) ) . toEqual ( [
1717 {
18- selector : "test" ,
18+ selector : ". test" ,
1919 property : "color" ,
2020 value : { alpha : 1 , b : 0 , g : 0 , r : 255 , type : "rgb" } ,
2121 } ,
@@ -30,7 +30,7 @@ describe("Parse CSS", () => {
3030 ` ;
3131 expect ( parseCss ( css ) ) . toEqual ( [
3232 {
33- selector : "test" ,
33+ selector : ". test" ,
3434 property : "backgroundImage" ,
3535 value : {
3636 type : "layers" ,
@@ -45,7 +45,7 @@ describe("Parse CSS", () => {
4545 } ,
4646 } ,
4747 {
48- selector : "test" ,
48+ selector : ". test" ,
4949 property : "backgroundPositionX" ,
5050 value : {
5151 type : "layers" ,
@@ -56,7 +56,7 @@ describe("Parse CSS", () => {
5656 } ,
5757 } ,
5858 {
59- selector : "test" ,
59+ selector : ". test" ,
6060 property : "backgroundPositionY" ,
6161 value : {
6262 type : "layers" ,
@@ -67,7 +67,7 @@ describe("Parse CSS", () => {
6767 } ,
6868 } ,
6969 {
70- selector : "test" ,
70+ selector : ". test" ,
7171 property : "backgroundSize" ,
7272 value : {
7373 type : "layers" ,
@@ -90,7 +90,7 @@ describe("Parse CSS", () => {
9090 } ,
9191 } ,
9292 {
93- selector : "test" ,
93+ selector : ". test" ,
9494 property : "backgroundRepeat" ,
9595 value : {
9696 type : "layers" ,
@@ -101,7 +101,7 @@ describe("Parse CSS", () => {
101101 } ,
102102 } ,
103103 {
104- selector : "test" ,
104+ selector : ". test" ,
105105 property : "backgroundAttachment" ,
106106 value : {
107107 type : "layers" ,
@@ -112,7 +112,7 @@ describe("Parse CSS", () => {
112112 } ,
113113 } ,
114114 {
115- selector : "test" ,
115+ selector : ". test" ,
116116 property : "backgroundOrigin" ,
117117 value : {
118118 type : "layers" ,
@@ -123,7 +123,7 @@ describe("Parse CSS", () => {
123123 } ,
124124 } ,
125125 {
126- selector : "test" ,
126+ selector : ". test" ,
127127 property : "backgroundClip" ,
128128 value : {
129129 type : "layers" ,
@@ -134,7 +134,7 @@ describe("Parse CSS", () => {
134134 } ,
135135 } ,
136136 {
137- selector : "test" ,
137+ selector : ". test" ,
138138 property : "backgroundColor" ,
139139 value : { alpha : 1 , b : 252 , g : 255 , r : 235 , type : "rgb" } ,
140140 } ,
@@ -149,31 +149,31 @@ describe("Parse CSS", () => {
149149 ` ;
150150 expect ( parseCss ( css ) ) . toEqual ( [
151151 {
152- selector : "test" ,
152+ selector : ". test" ,
153153 property : "backgroundImage" ,
154154 value : {
155155 type : "layers" ,
156156 value : [ { type : "keyword" , value : "none" } ] ,
157157 } ,
158158 } ,
159159 {
160- selector : "test" ,
160+ selector : ". test" ,
161161 property : "backgroundPositionX" ,
162162 value : {
163163 type : "layers" ,
164164 value : [ { type : "unit" , unit : "px" , value : 0 } ] ,
165165 } ,
166166 } ,
167167 {
168- selector : "test" ,
168+ selector : ". test" ,
169169 property : "backgroundPositionY" ,
170170 value : {
171171 type : "layers" ,
172172 value : [ { type : "unit" , unit : "px" , value : 0 } ] ,
173173 } ,
174174 } ,
175175 {
176- selector : "test" ,
176+ selector : ". test" ,
177177 property : "backgroundSize" ,
178178 value : {
179179 type : "layers" ,
@@ -194,7 +194,18 @@ describe("Parse CSS", () => {
194194 ] ) ;
195195 } ) ;
196196
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+
197207 test ( "parse first pseudo class as selector" , ( ) => {
208+ // E.g. :root
198209 expect ( parseCss ( `:first-pseudo:my-state { color: #ff0000 }` ) ) . toEqual ( [
199210 {
200211 selector : ":first-pseudo" ,
@@ -471,11 +482,33 @@ describe("Parse CSS", () => {
471482 } ) ;
472483
473484 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+ ] ) ;
475492 } ) ;
476493
477494 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+ ] ) ;
479512 } ) ;
480513} ) ;
481514
0 commit comments