1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

Fix regression in handling of procedural cosmetic filters

Related commit:
- 91caed32d3

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2185#issuecomment-1193862432
This commit is contained in:
Raymond Hill 2022-07-25 10:10:44 -04:00
parent a40eb5a40e
commit e2043b6554
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 15 additions and 4 deletions

View File

@ -828,7 +828,8 @@ FilterContainer.prototype.cssRuleFromProcedural = function(json) {
if ( pfilter.cssable !== true ) { return; }
const { tasks, action } = pfilter;
let mq;
if ( tasks !== undefined && tasks.length === 1 ) {
if ( tasks !== undefined ) {
if ( tasks.length > 1 ) { return; }
if ( tasks[0][0] !== ':matches-media' ) { return; }
mq = tasks[0][1];
}

View File

@ -1862,9 +1862,6 @@ Parser.prototype.SelectorCompiler = class {
}
const out = { selector: prefix };
if ( root && this.sheetSelectable(prefix) ) {
out.cssable = true;
}
if ( tasks.length !== 0 ) {
out.tasks = tasks;
@ -1875,6 +1872,19 @@ Parser.prototype.SelectorCompiler = class {
out.action = action;
}
// Flag to quickly find out whether the filter can be converted into
// a declarative CSS rule.
if (
root &&
(action === undefined || action[0] === ':style') &&
(
tasks.length === 0 ||
tasks.length === 1 && tasks[0][0] === ':matches-media'
)
) {
out.cssable = this.sheetSelectable(prefix);
}
return out;
}