Fix regression in applying procedural cosmetic filters

Related commit:
- 3573b6b32c
This commit is contained in:
Raymond Hill 2019-05-16 17:22:20 -04:00
parent 3573b6b32c
commit 1386429382
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 20 additions and 21 deletions

View File

@ -59,7 +59,7 @@ vAPI.userStylesheet = {
vAPI.DOMFilterer = class { vAPI.DOMFilterer = class {
constructor() { constructor() {
this.commitTimer = new vAPI.SafeAnimationFrame(( ) => this.commitNow); this.commitTimer = new vAPI.SafeAnimationFrame(this.commitNow.bind(this));
this.domIsReady = document.readyState !== 'loading'; this.domIsReady = document.readyState !== 'loading';
this.disabled = false; this.disabled = false;
this.listeners = []; this.listeners = [];

View File

@ -709,18 +709,17 @@ vAPI.DOMFilterer = (function() {
}; };
PSelector.prototype.operatorToTaskMap = undefined; PSelector.prototype.operatorToTaskMap = undefined;
const DOMProceduralFilterer = function(domFilterer) { const DOMProceduralFilterer = class {
this.domFilterer = domFilterer; constructor(domFilterer) {
this.domIsReady = false; this.domFilterer = domFilterer;
this.domIsWatched = false; this.domIsReady = false;
this.mustApplySelectors = false; this.domIsWatched = false;
this.selectors = new Map(); this.mustApplySelectors = false;
this.hiddenNodes = new Set(); this.selectors = new Map();
}; this.hiddenNodes = new Set();
}
DOMProceduralFilterer.prototype = { addProceduralSelectors(aa) {
addProceduralSelectors: function(aa) {
const addedSelectors = []; const addedSelectors = [];
let mustCommit = this.domIsWatched; let mustCommit = this.domIsWatched;
for ( let i = 0, n = aa.length; i < n; i++ ) { for ( let i = 0, n = aa.length; i < n; i++ ) {
@ -757,9 +756,9 @@ vAPI.DOMFilterer = (function() {
procedural: addedSelectors procedural: addedSelectors
}); });
} }
}, }
commitNow: function() { commitNow() {
if ( this.selectors.size === 0 || this.domIsReady === false ) { if ( this.selectors.size === 0 || this.domIsReady === false ) {
return; return;
} }
@ -804,18 +803,18 @@ vAPI.DOMFilterer = (function() {
this.domFilterer.unhideNode(node); this.domFilterer.unhideNode(node);
} }
//console.timeEnd('procedural selectors/dom layout changed'); //console.timeEnd('procedural selectors/dom layout changed');
}, }
createProceduralFilter: function(o) { createProceduralFilter(o) {
return new PSelector(o); return new PSelector(o);
}, }
onDOMCreated: function() { onDOMCreated() {
this.domIsReady = true; this.domIsReady = true;
this.domFilterer.commitNow(); this.domFilterer.commitNow();
}, }
onDOMChanged: function(addedNodes, removedNodes) { onDOMChanged(addedNodes, removedNodes) {
if ( this.selectors.size === 0 ) { return; } if ( this.selectors.size === 0 ) { return; }
this.mustApplySelectors = this.mustApplySelectors =
this.mustApplySelectors || this.mustApplySelectors ||
@ -869,7 +868,7 @@ vAPI.DOMFilterer = (function() {
onDOMChanged() { onDOMChanged() {
if ( super.onDOMChanged instanceof Function ) { if ( super.onDOMChanged instanceof Function ) {
super.onDOMChanged(arguments); super.onDOMChanged.apply(this, arguments);
} }
this.proceduralFilterer.onDOMChanged.apply( this.proceduralFilterer.onDOMChanged.apply(
this.proceduralFilterer, this.proceduralFilterer,