From 7d0714965f5e81451b5ef64cefac94593ab5757f Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 10 Nov 2022 15:34:02 -0500 Subject: [PATCH] [mv3] Fixed undue delay in 1st application of cosmetic procedural filters Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/discussions/2261#discussioncomment-4105044 --- platform/mv3/extension/js/scripting/css-procedural.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/mv3/extension/js/scripting/css-procedural.js b/platform/mv3/extension/js/scripting/css-procedural.js index 83dd51a59..93ca36d53 100644 --- a/platform/mv3/extension/js/scripting/css-procedural.js +++ b/platform/mv3/extension/js/scripting/css-procedural.js @@ -486,6 +486,9 @@ class ProceduralFilterer { this.styledNodes = new Set(); this.timer = undefined; this.addSelectors(selectors); + // Important: commit now (do not go through onDOMChanged) to be sure + // first pass is going to happen asap. + this.uBOL_commitNow(); } addSelectors() { @@ -506,8 +509,6 @@ class ProceduralFilterer { } uBOL_commitNow() { - //console.time('procedural selectors/dom layout changed'); - // https://github.com/uBlockOrigin/uBlock-issues/issues/341 // Be ready to unhide nodes which no longer matches any of // the procedural selectors. @@ -554,8 +555,8 @@ class ProceduralFilterer { styleNodes(nodes, styleToken) { if ( styleToken === undefined ) { for ( const node of nodes ) { - node.textContent = ''; node.remove(); + node.textContent = ''; } return; }