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 {
constructor() {
this.commitTimer = new vAPI.SafeAnimationFrame(( ) => this.commitNow);
this.commitTimer = new vAPI.SafeAnimationFrame(this.commitNow.bind(this));
this.domIsReady = document.readyState !== 'loading';
this.disabled = false;
this.listeners = [];

View File

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