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 ( selectors === undefined ) { return; }
if ( details === undefined ) { details = {}; }
const selectorsStr = Array.isArray(selectors) ? const selectorsStr = Array.isArray(selectors) ?
selectors.join(',\n') : selectors.join(',\n') :
selectors; selectors;
@ -233,7 +231,7 @@ vAPI.DOMFilterer = class {
vAPI.userStylesheet.add(selectorsStr + '\n{' + declarations + '}'); vAPI.userStylesheet.add(selectorsStr + '\n{' + declarations + '}');
this.commit(); this.commit();
if ( this.hasListeners() ) { if ( details.silent !== true && this.hasListeners() ) {
this.triggerListeners({ this.triggerListeners({
declarative: [ [ selectorsStr, declarations ] ] declarative: [ [ selectorsStr, declarations ] ]
}); });
@ -247,9 +245,6 @@ vAPI.DOMFilterer = class {
return; return;
} }
// Do not strongly enforce internal CSS rules.
if ( details.internal ) { return; }
const isGeneric= details.lazy === true; const isGeneric= details.lazy === true;
const isSimple = details.type === 'simple'; const isSimple = details.type === 'simple';
const isComplex = details.type === 'complex'; 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; } if ( selectors === undefined ) { return; }
const selectorsStr = Array.isArray(selectors) const selectorsStr = Array.isArray(selectors)
? selectors.join(',\n') ? selectors.join(',\n')
: selectors; : selectors;
if ( selectorsStr.length === 0 ) { return; } if ( selectorsStr.length === 0 ) { return; }
if ( details === undefined ) { details = {}; }
const entry = { const entry = {
selectors: selectorsStr, selectors: selectorsStr,
declarations, declarations,
@ -143,7 +142,7 @@ vAPI.DOMFilterer = class {
vAPI.userStylesheet.add(selectorsStr + '\n{' + declarations + '}'); vAPI.userStylesheet.add(selectorsStr + '\n{' + declarations + '}');
} }
this.commit(); this.commit();
if ( this.hasListeners() ) { if ( details.silent !== true && this.hasListeners() ) {
this.triggerListeners({ this.triggerListeners({
declarative: [ [ selectorsStr, declarations ] ] declarative: [ [ selectorsStr, declarations ] ]
}); });
@ -192,14 +191,14 @@ vAPI.DOMFilterer = class {
if ( this.excludedNodeSet.has(node) ) { return; } if ( this.excludedNodeSet.has(node) ) { return; }
if ( this.hideNodeAttr === undefined ) { return; } if ( this.hideNodeAttr === undefined ) { return; }
node.setAttribute(this.hideNodeAttr, ''); node.setAttribute(this.hideNodeAttr, '');
if ( this.hideNodeStyleSheetInjected === false ) { if ( this.hideNodeStyleSheetInjected ) { return; }
this.hideNodeStyleSheetInjected = true; this.hideNodeStyleSheetInjected = true;
this.addCSSRule( this.addCSSRule(
`[${this.hideNodeAttr}]`, `[${this.hideNodeAttr}]`,
'display:none!important;' 'display:none!important;',
{ silent: true }
); );
} }
}
unhideNode(node) { unhideNode(node) {
if ( this.hideNodeAttr === undefined ) { return; } if ( this.hideNodeAttr === undefined ) { return; }