1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 15:32:28 +02:00

Fix nth-of-type() not accepting identifier-based arguments

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2284#issuecomment-1271552479
This commit is contained in:
Raymond Hill 2022-10-07 09:12:45 -04:00
parent 93953f9b21
commit 3f8e3fe0c6
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1613,18 +1613,22 @@ Parser.prototype.SelectorCompiler = class {
out.push(`#${data.name}`); out.push(`#${data.name}`);
break; break;
case 'Nth': { case 'Nth': {
const a = parseInt(data.nth.a, 10) || null; if ( data.nth.type === 'AnPlusB' ) {
const b = parseInt(data.nth.b, 10) || null; const a = parseInt(data.nth.a, 10) || null;
if ( a !== null ) { const b = parseInt(data.nth.b, 10) || null;
out.push(`${a}n`); if ( a !== null ) {
if ( b === null ) { break; } out.push(`${a}n`);
if ( b < 0 ) { if ( b === null ) { break; }
if ( b < 0 ) {
out.push(`${b}`);
} else {
out.push(`+${b}`);
}
} else if ( b !== null ) {
out.push(`${b}`); out.push(`${b}`);
} else {
out.push(`+${b}`);
} }
} else if ( b !== null ) { } else if ( data.nth.type === 'Identifier' ) {
out.push(`${b}`); out.push(data.nth.name);
} }
break; break;
} }