From 3891b4d05097d6caf5ae5a77db81b0ab67e5677d Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 28 Oct 2021 10:36:26 -0400 Subject: [PATCH] query-selectable selectors are not necessarily sheet-selectable Related commits: - https://github.com/gorhill/uBlock/commit/4f923384de152fafaa52df8fa3e282cbe3db8659 - https://github.com/gorhill/uBlock/commit/97a33c957217acb7f1e3dae809558897d20952c2 - https://github.com/gorhill/uBlock/commit/ef07171f5a9e2e59054b930839658c0d8073b90e For instance, with "Experimental Web Platform features" enabled, the following filter becomes natively query-selectable: .fail:has(+ a > b) Meaning uBO won't need to emulate the `:has()` operator, it will be executed natively using `querySelectorAll()`. This commit fixes the erroneous assumption that a query-selectable is also sheet-selectable. --- src/js/static-filtering-parser.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index d72e6fd02..e804529eb 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -1404,9 +1404,12 @@ Parser.prototype.SelectorCompiler = class { const compiled = this.compileProceduralSelector(raw); if ( compiled === undefined ) { return false; } - out.compiled = compiled.selector !== compiled.raw - ? JSON.stringify(compiled) - : compiled.selector; + out.compiled = + compiled.selector !== compiled.raw || + this.sheetSelectable(compiled.selector) === false + ? JSON.stringify(compiled) + : compiled.selector; + return true; }