| Index: lib/elemHide.js |
| =================================================================== |
| --- a/lib/elemHide.js |
| +++ b/lib/elemHide.js |
| @@ -18,16 +18,17 @@ |
| "use strict"; |
| /** |
| * @fileOverview Element hiding implementation. |
| */ |
| const {ElemHideExceptions} = require("./elemHideExceptions"); |
| const {filterNotifier} = require("./filterNotifier"); |
| +const {suffixes} = require("./domain"); |
| /** |
| * The maximum number of selectors in a CSS rule. This is used by |
| * <code>{@link createStyleSheet}</code> to split up a long list of selectors |
| * into multiple rules. |
| * @const {number} |
| * @default |
| */ |
| @@ -164,25 +165,19 @@ |
| * |
| * @returns {Array.<string>} The list of selectors. |
| */ |
| function getConditionalSelectors(domain, specificOnly) |
| { |
| let selectors = []; |
| let excluded = new Set(); |
| - let currentDomain = domain; |
| - // This code is a performance hot-spot, which is why we've made certain |
| - // micro-optimisations. Please be careful before making changes. |
| - while (true) |
| + for (let currentDomain of suffixes(domain, !specificOnly)) |
| { |
| - if (specificOnly && currentDomain == "") |
| - break; |
| - |
| let filters = filtersByDomain.get(currentDomain); |
| if (filters) |
| { |
| for (let [filter, isIncluded] of filters) |
| { |
| if (!isIncluded) |
| { |
| excluded.add(filter); |
| @@ -193,22 +188,16 @@ |
| if ((excluded.size == 0 || !excluded.has(filter)) && |
| !ElemHideExceptions.getException(selector, domain)) |
| { |
| selectors.push(selector); |
| } |
| } |
| } |
| } |
| - |
| - if (currentDomain == "") |
| - break; |
| - |
| - let nextDot = currentDomain.indexOf("."); |
| - currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); |
| } |
| return selectors; |
| } |
| /** |
| * Returns the default style sheet that applies on all domains. |
| * @returns {string} |