mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-13 02:14:17 +01: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:
parent
07178e6416
commit
743210f5df
1 changed files with 23 additions and 0 deletions
|
@ -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':
|
||||
|
|
Loading…
Reference in a new issue