Skip to content

Commit

Permalink
Fix regression in handling of procedural cosmetic filters
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jul 25, 2022
1 parent a40eb5a commit e2043b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/js/cosmetic-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
16 changes: 13 additions & 3 deletions src/js/static-filtering-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit e2043b6

Please sign in to comment.