Skip to content

Commit aaa1797

Browse files
committed
fix: css parser fix
when inside a pseudo-class, only `)` is a valid end, and when outside, only `{` is - reflect that in the logic
1 parent 402a322 commit aaa1797

File tree

1 file changed

+2
-3
lines changed
  • packages/svelte/src/compiler/phases/1-parse/read

1 file changed

+2
-3
lines changed

packages/svelte/src/compiler/phases/1-parse/read/style.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { error } from '../../../errors.js';
22

33
const REGEX_MATCHER = /^[~^$*|]?=/;
4-
const REGEX_CLOSING_PAREN = /(?<!\\)\)/; // \) is a way of escaping a closing paren, so we need to exclude it
54
const REGEX_CLOSING_BRACKET = /[\s\]]/;
65
const REGEX_ATTRIBUTE_FLAGS = /^[a-zA-Z]+/; // only `i` and `s` are valid today, but make it future-proof
76
const REGEX_COMBINATOR_WHITESPACE = /^\s*(\+|~|>|\|\|)\s*/;
@@ -161,7 +160,7 @@ function read_selector_list(parser, inside_pseudo_class = false) {
161160

162161
parser.allow_whitespace();
163162

164-
if (parser.match('{') || (inside_pseudo_class && parser.match(')'))) {
163+
if (inside_pseudo_class ? parser.match(')') : parser.match('{')) {
165164
return {
166165
type: 'SelectorList',
167166
start,
@@ -310,7 +309,7 @@ function read_selector(parser, inside_pseudo_class = false) {
310309
const index = parser.index;
311310
parser.allow_whitespace();
312311

313-
if (parser.match('{') || parser.match(',') || (inside_pseudo_class && parser.match(')'))) {
312+
if (parser.match(',') || (inside_pseudo_class ? parser.match(')') : parser.match('{'))) {
314313
parser.index = index;
315314

316315
return {

0 commit comments

Comments
 (0)