Skip to content

Commit

Permalink
parserlib: fix <forgiving-selector-list>
Browse files Browse the repository at this point in the history
  • Loading branch information
tophf committed Mar 26, 2024
1 parent 1f1c295 commit 0e34407
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
17 changes: 9 additions & 8 deletions js/csslint/parserlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -1155,13 +1155,14 @@
* @param {TokenStream} stream
* @param {Token} [tok]
* @param {boolean} [relative]
* @param {boolean} [lax]
* @return {TokenValue<TokenSelector>[]|void}
*/
_selectorsGroup(stream, tok, relative) {
_selectorsGroup(stream, tok, relative, lax) {
const selectors = [];
let comma;
while ((tok = this._selector(stream, tok, relative))) {
selectors.push(tok);
while ((tok = this._selector(stream, tok, relative)) || lax) {
if (tok) selectors.push(tok);
if ((tok = stream.token).isVar) tok = stream.grab();
if (!(comma = tok.id === COMMA)) break;
tok = null;
Expand Down Expand Up @@ -1773,13 +1774,13 @@
let tok = stream.grab();
try {
if (tok.id === LPAREN) {
a = this._selectorsGroup(stream);
a = this._selectorsGroup(stream, undefined, false, true);
stream.matchSmart(RPAREN, OrDieReusing);
tok = stream.grab();
}
if (a && B.to.has(tok)) {
stream.matchSmart(LPAREN, OrDie);
b = this._selectorsGroup(stream);
b = this._selectorsGroup(stream, undefined, false, true);
stream.matchSmart(RPAREN, OrDieReusing);
tok = stream.grab();
}
Expand Down Expand Up @@ -1893,7 +1894,7 @@
tok.col -= colons.length;
tok.offset -= colons.length;
tok.type = 'pseudo';
let expr, n, x;
let expr, n, x, lax;
if ((n = tok.name)) {
stream._pair = RPAREN;
if (n === 'nth-child' || n === 'nth-last-child') {
Expand All @@ -1904,8 +1905,8 @@
else if (t2.id === RPAREN) x = true;
else stream._failure('', t1);
}
if (n === 'not' || n === 'is' || n === 'where' || n === 'any' || n === 'has') {
x = this._selectorsGroup(stream, undefined, n === 'has');
if (n === 'not' || (lax = n === 'is' || n === 'where' || n === 'any') || n === 'has') {
x = this._selectorsGroup(stream, undefined, n === 'has', lax);
if (!x) stream._failure('a selector');
if (expr) expr.push(...x); else expr = x;
stream.matchSmart(RPAREN, OrDieReusing);
Expand Down
3 changes: 1 addition & 2 deletions tools/test-css-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,4 @@ warning 550 32 Expected [ [ root | nearest | self ] || [ block | inline | vertic
error 570 15 Expected "{" but found "too".
error 571 18 Expected "(" but found "{".
error 572 8 Expected "{" but found "to".
error 573 30 Unexpected ")".
warning 576 23 Expected [ <named-or-hex-color> | color-mix() | color() | hsl() | hwb() | lab() | lch() | light-dark() | rgb() | hsla() | rgba() | oklab() | oklch() ]#{2} but found "red".
warning 576 23 Expected [ <named-or-hex-color> | color-mix() | color() | hsl() | hwb() | lab() | lch() | light-dark() | rgb() | hsla() | rgba() | oklab() | oklch() ]#{2} but found "red".

0 comments on commit 0e34407

Please sign in to comment.