Skip to content

Commit 22c921c

Browse files
committed
fix
1 parent 27da54d commit 22c921c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/styles/parser/selector/css-selector-parser.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,13 @@ export class CSSSelectorParser {
311311
const beforeTrivials = /^\(\s*/u.exec(source);
312312
if (!beforeTrivials?.[0]) return;
313313
let withinParen = false;
314-
for (let index = end - 1; index < code.length; index++) {
314+
315+
for (
316+
// Search from `end - 1` since it may be in the current source.
317+
let index = end - 1;
318+
index < code.length;
319+
index++
320+
) {
315321
const ch = code[index];
316322
if (ch === ")") {
317323
withinParen = true;
@@ -336,12 +342,12 @@ export class CSSSelectorParser {
336342
const afterTrivials = /\s*\)$/u.exec(source);
337343
if (!afterTrivials?.[0]) return;
338344
let withinParen = false;
339-
for (let index = start; index >= 0; index--) {
345+
for (let index = start - 1; index >= 0; index--) {
340346
const ch = code[index];
341347
if (ch === "(") {
342348
withinParen = true;
343349
break;
344-
} else if (ch?.trim() && index !== start) {
350+
} else if (ch?.trim()) {
345351
return;
346352
}
347353
}

0 commit comments

Comments
 (0)