mirror of https://github.com/gorhill/uBlock.git
Fix procedural to declarative conversion
This commit is contained in:
parent
5d596b644d
commit
07fae6a0d1
|
@ -671,25 +671,30 @@ FilterContainer.prototype.disableSurveyor = function(details) {
|
|||
FilterContainer.prototype.cssRuleFromProcedural = function(pfilter) {
|
||||
if ( pfilter.cssable !== true ) { return; }
|
||||
const { tasks, action } = pfilter;
|
||||
let mq;
|
||||
if ( tasks !== undefined ) {
|
||||
if ( tasks.length > 1 ) { return; }
|
||||
let mq, selector;
|
||||
if ( Array.isArray(tasks) ) {
|
||||
if ( tasks[0][0] !== 'matches-media' ) { return; }
|
||||
mq = tasks[0][1];
|
||||
if ( tasks.length > 2 ) { return; }
|
||||
if ( tasks.length === 2 ) {
|
||||
if ( tasks[1][0] !== 'spath' ) { return; }
|
||||
selector = tasks[1][1];
|
||||
}
|
||||
}
|
||||
let style;
|
||||
if ( Array.isArray(action) ) {
|
||||
if ( action[0] !== 'style' ) { return; }
|
||||
selector = selector || pfilter.selector;
|
||||
style = action[1];
|
||||
}
|
||||
if ( mq === undefined && style === undefined ) { return; }
|
||||
if ( mq === undefined && style === undefined && selector === undefined ) { return; }
|
||||
if ( mq === undefined ) {
|
||||
return `${pfilter.selector}\n{${style}}`;
|
||||
return `${selector}\n{${style}}`;
|
||||
}
|
||||
if ( style === undefined ) {
|
||||
return `@media ${mq} {\n${pfilter.selector}\n{display:none!important;}\n}`;
|
||||
return `@media ${mq} {\n${selector}\n{display:none!important;}\n}`;
|
||||
}
|
||||
return `@media ${mq} {\n${pfilter.selector}\n{${style}}\n}`;
|
||||
return `@media ${mq} {\n${selector}\n{${style}}\n}`;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -3112,9 +3112,11 @@ class ExtSelectorCompiler {
|
|||
isCssable(r) {
|
||||
if ( r instanceof Object === false ) { return false; }
|
||||
if ( Array.isArray(r.action) && r.action[0] !== 'style' ) { return false; }
|
||||
if ( r.tasks === undefined ) { return true; }
|
||||
if ( r.tasks.length > 1 ) { return false; }
|
||||
if ( r.tasks[0][0] === 'matches-media' ) { return true; }
|
||||
if ( Array.isArray(r.tasks) === false ) { return true; }
|
||||
if ( r.tasks[0][0] === 'matches-media' ) {
|
||||
if ( r.tasks.length === 1 ) { return true; }
|
||||
if ( r.tasks.length === 2 && r.tasks[1][0] === 'spath' ) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue