Skip to content

Commit

Permalink
selectors may start with combinators (#279)
Browse files Browse the repository at this point in the history
* selectors may start with combinators

* add tests

Co-authored-by: amendaros <[email protected]>
Co-authored-by: Martin Aeschlimann <[email protected]>
  • Loading branch information
3 people authored Sep 2, 2022
1 parent 028dc85 commit f967abc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/parser/cssParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1413,10 +1413,10 @@ export class Parser {
if (!this.hasWhitespace() && this.accept(TokenType.ParenthesisL)) {
const tryAsSelector = () => {
const selectors = this.create(nodes.Node);
if (!selectors.addChild(this._parseSelector(false))) {
if (!selectors.addChild(this._parseSelector(true))) {
return null;
}
while (this.accept(TokenType.Comma) && selectors.addChild(this._parseSelector(false))) {
while (this.accept(TokenType.Comma) && selectors.addChild(this._parseSelector(true))) {
// loop
}
if (this.peek(TokenType.ParenthesisR)) {
Expand Down
4 changes: 4 additions & 0 deletions src/test/css/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ suite('CSS - Parser', () => {
assertNode(':global(.output ::selection)', parser, parser._parsePseudo.bind(parser)); // #49010
assertNode(':matches(:hover, :focus)', parser, parser._parsePseudo.bind(parser)); // #49010
assertNode(':host([foo=bar][bar=foo])', parser, parser._parsePseudo.bind(parser)); // #49589
assertNode(':has(> .test)', parser, parser._parsePseudo.bind(parser)); // #250
assertNode(':has(~ .test)', parser, parser._parsePseudo.bind(parser)); // #250
assertNode(':has(+ .test)', parser, parser._parsePseudo.bind(parser)); // #250
assertNode(':has(~ div .test)', parser, parser._parsePseudo.bind(parser)); // #250
assertError('::', parser, parser._parsePseudo.bind(parser), ParseError.IdentifierExpected);
assertError(':: foo', parser, parser._parsePseudo.bind(parser), ParseError.IdentifierExpected);
});
Expand Down

0 comments on commit f967abc

Please sign in to comment.