Properly handle unsupported `nth-child(an of selector)

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2284#issuecomment-1280325910
This commit is contained in:
Raymond Hill 2022-10-17 07:26:51 -04:00
parent 25b0a2c90c
commit 04119e9cdd
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 4 additions and 1 deletions

View File

@ -1614,6 +1614,7 @@ Parser.prototype.SelectorCompiler = class {
out.push(`#${data.name}`); out.push(`#${data.name}`);
break; break;
case 'Nth': { case 'Nth': {
if ( data.selector !== null ) { return; }
if ( data.nth.type === 'AnPlusB' ) { if ( data.nth.type === 'AnPlusB' ) {
const a = parseInt(data.nth.a, 10) || null; const a = parseInt(data.nth.a, 10) || null;
const b = parseInt(data.nth.b, 10) || null; const b = parseInt(data.nth.b, 10) || null;
@ -1637,7 +1638,9 @@ Parser.prototype.SelectorCompiler = class {
case 'PseudoElementSelector': case 'PseudoElementSelector':
out.push(`:${data.name}`); out.push(`:${data.name}`);
if ( Array.isArray(part.args) ) { if ( Array.isArray(part.args) ) {
out.push(`(${this.astSerialize(part.args)})`); const arg = this.astSerialize(part.args);
if ( typeof arg !== 'string' ) { return; }
out.push(`(${arg})`);
} }
break; break;
case 'Raw': case 'Raw':