Fix internal cosmetic filter being reported in the logger

Regression from:
- 62387fb87a

Repro steps were:
- Open the logger
- Navigate to `https://news.ycombinator.com/`
- Select an element using the element picker
- Click "Preview"

An attribute selector used internally by uBO to
hide targeted nodes was being reported in the
logger.
This commit is contained in:
Raymond Hill 2019-06-20 07:14:34 -04:00
parent ca89a3895f
commit 793aca7ddb
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
2 changed files with 11 additions and 17 deletions

View file

@ -221,11 +221,9 @@ vAPI.DOMFilterer = class {
}
}
addCSSRule(selectors, declarations, details) {
addCSSRule(selectors, declarations, details = {}) {
if ( selectors === undefined ) { return; }
if ( details === undefined ) { details = {}; }
const selectorsStr = Array.isArray(selectors) ?
selectors.join(',\n') :
selectors;
@ -233,7 +231,7 @@ vAPI.DOMFilterer = class {
vAPI.userStylesheet.add(selectorsStr + '\n{' + declarations + '}');
this.commit();
if ( this.hasListeners() ) {
if ( details.silent !== true && this.hasListeners() ) {
this.triggerListeners({
declarative: [ [ selectorsStr, declarations ] ]
});
@ -247,9 +245,6 @@ vAPI.DOMFilterer = class {
return;
}
// Do not strongly enforce internal CSS rules.
if ( details.internal ) { return; }
const isGeneric= details.lazy === true;
const isSimple = details.type === 'simple';
const isComplex = details.type === 'complex';

View file

@ -120,13 +120,12 @@ vAPI.DOMFilterer = class {
}
}
addCSSRule(selectors, declarations, details) {
addCSSRule(selectors, declarations, details = {}) {
if ( selectors === undefined ) { return; }
const selectorsStr = Array.isArray(selectors)
? selectors.join(',\n')
: selectors;
if ( selectorsStr.length === 0 ) { return; }
if ( details === undefined ) { details = {}; }
const entry = {
selectors: selectorsStr,
declarations,
@ -143,7 +142,7 @@ vAPI.DOMFilterer = class {
vAPI.userStylesheet.add(selectorsStr + '\n{' + declarations + '}');
}
this.commit();
if ( this.hasListeners() ) {
if ( details.silent !== true && this.hasListeners() ) {
this.triggerListeners({
declarative: [ [ selectorsStr, declarations ] ]
});
@ -192,13 +191,13 @@ vAPI.DOMFilterer = class {
if ( this.excludedNodeSet.has(node) ) { return; }
if ( this.hideNodeAttr === undefined ) { return; }
node.setAttribute(this.hideNodeAttr, '');
if ( this.hideNodeStyleSheetInjected === false ) {
this.hideNodeStyleSheetInjected = true;
this.addCSSRule(
`[${this.hideNodeAttr}]`,
'display:none!important;'
);
}
if ( this.hideNodeStyleSheetInjected ) { return; }
this.hideNodeStyleSheetInjected = true;
this.addCSSRule(
`[${this.hideNodeAttr}]`,
'display:none!important;',
{ silent: true }
);
}
unhideNode(node) {