@@ -175,6 +175,38 @@ function parseSelector(
175
175
}
176
176
}
177
177
178
+ function readValueWithParenthesis ( ) : string {
179
+ selectorIndex += 1 ;
180
+ const start = selectorIndex ;
181
+ let counter = 1 ;
182
+
183
+ for (
184
+ ;
185
+ counter > 0 && selectorIndex < selector . length ;
186
+ selectorIndex ++
187
+ ) {
188
+ if (
189
+ selector . charCodeAt ( selectorIndex ) ===
190
+ CharCode . LeftParenthesis &&
191
+ ! isEscaped ( selectorIndex )
192
+ ) {
193
+ counter ++ ;
194
+ } else if (
195
+ selector . charCodeAt ( selectorIndex ) ===
196
+ CharCode . RightParenthesis &&
197
+ ! isEscaped ( selectorIndex )
198
+ ) {
199
+ counter -- ;
200
+ }
201
+ }
202
+
203
+ if ( counter ) {
204
+ throw new Error ( "Parenthesis not matched" ) ;
205
+ }
206
+
207
+ return unescapeCSS ( selector . slice ( start , selectorIndex - 1 ) ) ;
208
+ }
209
+
178
210
function isEscaped ( pos : number ) : boolean {
179
211
let slashCount = 0 ;
180
212
@@ -434,6 +466,11 @@ function parseSelector(
434
466
tokens . push ( {
435
467
type : SelectorType . PseudoElement ,
436
468
name : getName ( 2 ) . toLowerCase ( ) ,
469
+ data :
470
+ selector . charCodeAt ( selectorIndex ) ===
471
+ CharCode . LeftParenthesis
472
+ ? readValueWithParenthesis ( )
473
+ : null ,
437
474
} ) ;
438
475
continue ;
439
476
}
@@ -470,35 +507,7 @@ function parseSelector(
470
507
471
508
selectorIndex += 1 ;
472
509
} else {
473
- selectorIndex += 1 ;
474
- const start = selectorIndex ;
475
- let counter = 1 ;
476
-
477
- for (
478
- ;
479
- counter > 0 && selectorIndex < selector . length ;
480
- selectorIndex ++
481
- ) {
482
- if (
483
- selector . charCodeAt ( selectorIndex ) ===
484
- CharCode . LeftParenthesis &&
485
- ! isEscaped ( selectorIndex )
486
- ) {
487
- counter ++ ;
488
- } else if (
489
- selector . charCodeAt ( selectorIndex ) ===
490
- CharCode . RightParenthesis &&
491
- ! isEscaped ( selectorIndex )
492
- ) {
493
- counter -- ;
494
- }
495
- }
496
-
497
- if ( counter ) {
498
- throw new Error ( "Parenthesis not matched" ) ;
499
- }
500
-
501
- data = selector . slice ( start , selectorIndex - 1 ) ;
510
+ data = readValueWithParenthesis ( ) ;
502
511
503
512
if ( stripQuotesFromPseudos . has ( name ) ) {
504
513
const quot = data . charCodeAt ( 0 ) ;
0 commit comments