Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/elemHide.js

Issue 29893628: Issue 6957 - Skip selector lookup for unknown domains (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Sept. 27, 2018, 10:01 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHide.js
===================================================================
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -354,33 +354,39 @@
/**
* Generates a style sheet for a given domain based on the current set of
* filters.
*
* @param {string} domain The domain.
* @param {boolean} [specificOnly=false] Whether selectors from generic
* filters should be included.
+ * @param {boolean} [includeSelectors=true] Whether the return value should
+ * include a separate list of selectors.
*
* @returns {ElemHideStyleSheet} An object containing the CSS code and the
* list of selectors.
*/
- generateStyleSheetForDomain(domain, specificOnly = false)
+ generateStyleSheetForDomain(domain, specificOnly = false,
+ includeSelectors = true)
{
let knownSuffix = domain ? getKnownSuffix(domain) : "";
- let selectors = getConditionalSelectorsForDomain(knownSuffix, specificOnly);
+ let selectors = [];
+ if (includeSelectors || knownSuffix != "")
+ selectors = getConditionalSelectorsForDomain(knownSuffix, specificOnly);
+
let code = specificOnly ? createStyleSheet(selectors) :
knownSuffix == "" ? getCommonStyleSheet() :
(getDefaultStyleSheet() + createStyleSheet(selectors));
- if (!specificOnly)
+ if (includeSelectors && !specificOnly)
selectors = getUnconditionalSelectors().concat(selectors);
- return {code, selectors};
+ return {code, selectors: includeSelectors ? selectors : null};
}
};
/**
* Splits a list of selectors into groups determined by the value of
* <code>{@link selectorGroupSize}</code>.
*
* @param {Array.<string>} selectors
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld