Skip to content

Commit

Permalink
[mv3] Use Set instead of array to avoid spurious script updates
Browse files Browse the repository at this point in the history
Spurious updates to registered content scripts would occur when
using some regional lists, for example DEU would cause spurious
updates to registered script `css-procedural`.
  • Loading branch information
gorhill committed Nov 10, 2022
1 parent abe2ecb commit 5b6fc43
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions platform/mv3/extension/js/scripting-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,14 @@ function registerProcedural(context, proceduralDetails) {
const { before, filteringModeDetails, rulesetsDetails } = context;

const js = [];
const hostnameMatches = [];
const hostnameMatches = new Set();
for ( const details of rulesetsDetails ) {
if ( details.css.procedural === 0 ) { continue; }
js.push(`/rulesets/scripting/procedural/${details.id}.js`);
if ( proceduralDetails.has(details.id) ) {
hostnameMatches.push(...proceduralDetails.get(details.id));
for ( const hn of proceduralDetails.get(details.id) ) {
hostnameMatches.add(hn);
}
}
}

Expand Down

0 comments on commit 5b6fc43

Please sign in to comment.