fix: css parser fix

when inside a pseudo-class, only `)` is a valid end, and when outside, only `{` is - reflect that in the logic
pull/9757/head
Simon Holthausen 1 year ago
parent 402a322317
commit aaa1797ed8

@ -1,7 +1,6 @@
import { error } from '../../../errors.js'; import { error } from '../../../errors.js';
const REGEX_MATCHER = /^[~^$*|]?=/; const REGEX_MATCHER = /^[~^$*|]?=/;
const REGEX_CLOSING_PAREN = /(?<!\\)\)/; // \) is a way of escaping a closing paren, so we need to exclude it
const REGEX_CLOSING_BRACKET = /[\s\]]/; const REGEX_CLOSING_BRACKET = /[\s\]]/;
const REGEX_ATTRIBUTE_FLAGS = /^[a-zA-Z]+/; // only `i` and `s` are valid today, but make it future-proof const REGEX_ATTRIBUTE_FLAGS = /^[a-zA-Z]+/; // only `i` and `s` are valid today, but make it future-proof
const REGEX_COMBINATOR_WHITESPACE = /^\s*(\+|~|>|\|\|)\s*/; const REGEX_COMBINATOR_WHITESPACE = /^\s*(\+|~|>|\|\|)\s*/;
@ -161,7 +160,7 @@ function read_selector_list(parser, inside_pseudo_class = false) {
parser.allow_whitespace(); parser.allow_whitespace();
if (parser.match('{') || (inside_pseudo_class && parser.match(')'))) { if (inside_pseudo_class ? parser.match(')') : parser.match('{')) {
return { return {
type: 'SelectorList', type: 'SelectorList',
start, start,
@ -310,7 +309,7 @@ function read_selector(parser, inside_pseudo_class = false) {
const index = parser.index; const index = parser.index;
parser.allow_whitespace(); parser.allow_whitespace();
if (parser.match('{') || parser.match(',') || (inside_pseudo_class && parser.match(')'))) { if (parser.match(',') || (inside_pseudo_class ? parser.match(')') : parser.match('{'))) {
parser.index = index; parser.index = index;
return { return {

Loading…
Cancel
Save