mirror of https://github.com/gorhill/uBlock.git
Fix detection of leading combinators
Related feedback: https://github.com/uBlockOrigin/uBlock-issues/issues/2778#issuecomment-1722488224
This commit is contained in:
parent
d005e3f3ac
commit
20d3c6a466
|
@ -3493,9 +3493,9 @@ class ExtSelectorCompiler {
|
||||||
const out = { selector: '' };
|
const out = { selector: '' };
|
||||||
const prelude = [];
|
const prelude = [];
|
||||||
const tasks = [];
|
const tasks = [];
|
||||||
for ( let i = 0; i < parts.length; i++ ) {
|
let startOfSelector = true;
|
||||||
|
for ( const part of parts ) {
|
||||||
if ( out.action !== undefined ) { return; }
|
if ( out.action !== undefined ) { return; }
|
||||||
const part = parts[i];
|
|
||||||
const { data } = part;
|
const { data } = part;
|
||||||
switch ( data.type ) {
|
switch ( data.type ) {
|
||||||
case 'ActionSelector': {
|
case 'ActionSelector': {
|
||||||
|
@ -3522,13 +3522,17 @@ class ExtSelectorCompiler {
|
||||||
const s = this.astSerializePart(part);
|
const s = this.astSerializePart(part);
|
||||||
if ( s === undefined ) { return; }
|
if ( s === undefined ) { return; }
|
||||||
prelude.push(s);
|
prelude.push(s);
|
||||||
|
startOfSelector = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'Combinator': {
|
case 'Combinator': {
|
||||||
const s = this.astSerializePart(part);
|
const s = this.astSerializePart(part);
|
||||||
if ( s === undefined ) { return; }
|
if ( s === undefined ) { return; }
|
||||||
if ( i !== 0 || prelude.length !== 0 ) { prelude.push(' '); }
|
if ( startOfSelector === false || prelude.length !== 0 ) {
|
||||||
|
prelude.push(' ');
|
||||||
|
}
|
||||||
if ( s !== ' ' ) { prelude.push(s, ' '); }
|
if ( s !== ' ' ) { prelude.push(s, ' '); }
|
||||||
|
startOfSelector = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'ProceduralSelector': {
|
case 'ProceduralSelector': {
|
||||||
|
@ -3545,14 +3549,17 @@ class ExtSelectorCompiler {
|
||||||
const args = this.compileArgumentAst(data.name, part.args);
|
const args = this.compileArgumentAst(data.name, part.args);
|
||||||
if ( args === undefined ) { return; }
|
if ( args === undefined ) { return; }
|
||||||
tasks.push([ data.name, args ]);
|
tasks.push([ data.name, args ]);
|
||||||
|
startOfSelector = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'Selector':
|
case 'Selector':
|
||||||
if ( prelude.length !== 0 ) {
|
if ( prelude.length !== 0 ) {
|
||||||
prelude.push(', ');
|
prelude.push(', ');
|
||||||
}
|
}
|
||||||
|
startOfSelector = true;
|
||||||
break;
|
break;
|
||||||
case 'SelectorList':
|
case 'SelectorList':
|
||||||
|
startOfSelector = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue