diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index a84112c034fe5..ffe5ed12e5841 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -3364,7 +3364,7 @@ class ExtSelectorCompiler { out.push(`.${data.name}`); break; case 'Combinator': - out.push(data.name === ' ' ? ' ' : ` ${data.name} `); + out.push(data.name); break; case 'Identifier': if ( this.reInvalidIdentifier.test(data.name) ) { return; } @@ -3436,6 +3436,28 @@ class ExtSelectorCompiler { return out.join(''); } + astAppendPart(part, out) { + const { data } = part; + switch ( data.type ) { + case 'Combinator': { + const s = this.astSerializePart(part); + if ( s === undefined ) { return false; } + if ( out.length === 0 ) { + if ( s !== ' ' ) { + out.push(s, ' '); + } + } else { + out.push(' '); + if ( s !== ' ' ) { + out.push(s, ' '); + } + } + break; + } + } + return true; + } + astSerialize(parts, plainCSS = true) { const out = []; for ( const part of parts ) { @@ -3443,7 +3465,6 @@ class ExtSelectorCompiler { switch ( data.type ) { case 'AttributeSelector': case 'ClassSelector': - case 'Combinator': case 'Identifier': case 'IdSelector': case 'Nth': @@ -3455,6 +3476,9 @@ class ExtSelectorCompiler { out.push(s); break; } + case 'Combinator': + if ( this.astAppendPart(part, out) === false ) { return; } + break; case 'Raw': if ( plainCSS ) { return; } out.push(this.astSerializePart(part)); @@ -3499,7 +3523,6 @@ class ExtSelectorCompiler { } case 'AttributeSelector': case 'ClassSelector': - case 'Combinator': case 'IdSelector': case 'PseudoClassSelector': case 'PseudoElementSelector': @@ -3509,6 +3532,10 @@ class ExtSelectorCompiler { prelude.push(component); break; } + case 'Combinator': { + if ( this.astAppendPart(part, prelude) === false ) { return; } + break; + } case 'ProceduralSelector': { if ( prelude.length !== 0 ) { let spath = prelude.join('');