1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

Fix incomplete parsing of nth-of-type() and some other pseudo-classes

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2284

Regression from:
- a71b71e4c8
This commit is contained in:
Raymond Hill 2022-09-24 17:27:20 -04:00
parent 07178e6416
commit 743210f5df
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1515,6 +1515,10 @@ Parser.prototype.SelectorCompiler = class {
args = out;
out.push({ data });
break;
case 'Nth': {
out.push({ data });
break;
}
case 'PseudoClassSelector':
case 'PseudoElementSelector':
if ( head ) { args = []; }
@ -1594,9 +1598,28 @@ Parser.prototype.SelectorCompiler = class {
case 'Combinator':
out.push(data.name === ' ' ? ' ' : ` ${data.name} `);
break;
case 'Identifier':
out.push(data.name);
break;
case 'IdSelector':
out.push(`#${data.name}`);
break;
case 'Nth': {
const a = parseInt(data.nth.a, 10) || null;
const b = parseInt(data.nth.b, 10) || null;
if ( a !== null ) {
out.push(`${a}n`);
if ( b === null ) { break; }
if ( b < 0 ) {
out.push(`${b}`);
} else {
out.push(`+${b}`);
}
} else if ( b !== null ) {
out.push(`${b}`);
}
break;
}
case 'ActionSelector':
case 'PseudoClassSelector':
case 'PseudoElementSelector':