code review re. #1912

This commit is contained in:
gorhill 2016-09-24 14:42:31 -04:00
parent 95ec573141
commit 21f3dc83ec
1 changed files with 8 additions and 6 deletions

View File

@ -296,6 +296,7 @@ var domFilterer = {
enabled: true, enabled: true,
hiddenId: vAPI.randomToken(), hiddenId: vAPI.randomToken(),
hiddenNodeCount: 0, hiddenNodeCount: 0,
hiddenNodeEnforcer: false,
loggerEnabled: undefined, loggerEnabled: undefined,
styleTags: [], styleTags: [],
@ -434,10 +435,6 @@ var domFilterer = {
this.job1._0.length = 0; this.job1._0.length = 0;
} }
if ( styleText !== '' ) {
this.addStyleTag(styleText);
}
// Simple selectors: incremental. // Simple selectors: incremental.
// Stock job 2 = simple css selectors/hide // Stock job 2 = simple css selectors/hide
@ -472,14 +469,19 @@ var domFilterer = {
// user styles, this allows uBO to win. // user styles, this allows uBO to win.
var commitHit = this.hiddenNodeCount !== beforeHiddenNodeCount; var commitHit = this.hiddenNodeCount !== beforeHiddenNodeCount;
if ( commitHit ) { if ( commitHit ) {
if ( beforeHiddenNodeCount === 0 ) { if ( this.hiddenNodeEnforcer === false ) {
this.addStyleTag(':root *[' + this.hiddenId + '][hidden] { display: none !important; }'); styleText += '\n:root *[' + this.hiddenId + '][hidden] { display: none !important; }';
this.hiddenNodeEnforcer = true;
} }
this.addedNodesHandlerMissCount = 0; this.addedNodesHandlerMissCount = 0;
} else { } else {
this.addedNodesHandlerMissCount += 1; this.addedNodesHandlerMissCount += 1;
} }
if ( styleText !== '' ) {
this.addStyleTag(styleText);
}
// Un-hide nodes previously hidden. // Un-hide nodes previously hidden.
i = complexSelectorsOldResultSet.size; i = complexSelectorsOldResultSet.size;
if ( i !== 0 ) { if ( i !== 0 ) {