@@ -175,6 +175,38 @@ function parseSelector(
175175 }
176176 }
177177
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+
178210 function isEscaped ( pos : number ) : boolean {
179211 let slashCount = 0 ;
180212
@@ -434,6 +466,11 @@ function parseSelector(
434466 tokens . push ( {
435467 type : SelectorType . PseudoElement ,
436468 name : getName ( 2 ) . toLowerCase ( ) ,
469+ data :
470+ selector . charCodeAt ( selectorIndex ) ===
471+ CharCode . LeftParenthesis
472+ ? readValueWithParenthesis ( )
473+ : null ,
437474 } ) ;
438475 continue ;
439476 }
@@ -470,35 +507,7 @@ function parseSelector(
470507
471508 selectorIndex += 1 ;
472509 } 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 ( ) ;
502511
503512 if ( stripQuotesFromPseudos . has ( name ) ) {
504513 const quot = data . charCodeAt ( 0 ) ;
0 commit comments