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

Unified Diff: lib/elemHide.js

Issue 29897558: Issue 6957 - Add rulesFromStyleSheet function to ElemHide module (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Oct. 1, 2018, 2:56 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 | test/elemHide.js » ('j') | 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
@@ -401,16 +401,39 @@
}
}
return {code, selectors: includeSelectors ? selectors : null};
}
};
/**
+ * Yields rules from a style sheet returned by
+ * <code>{@link createStyleSheet}</code>.
+ *
+ * @param {string} styleSheet A style sheet returned by
+ * <code>{@link createStyleSheet}</code>. If the given style sheet is
+ * <em>not</em> a value previously returned by a call to
+ * <code>{@link createStyleSheet}</code>, the behavior is undefined.
+ * @yields {string} A rule from the given style sheet.
+ */
+function* rulesFromStyleSheet(styleSheet)
+{
+ let startIndex = 0;
+ while (startIndex < styleSheet.length)
+ {
+ let ruleTerminatorIndex = styleSheet.indexOf("\n", startIndex);
+ yield styleSheet.substring(startIndex, ruleTerminatorIndex);
+ startIndex = ruleTerminatorIndex + 1;
+ }
+}
+
+exports.rulesFromStyleSheet = rulesFromStyleSheet;
+
+/**
* Splits a list of selectors into groups determined by the value of
* <code>{@link selectorGroupSize}</code>.
*
* @param {Array.<string>} selectors
* @yields {Array.<string>}
*/
function* splitSelectors(selectors)
{
« no previous file with comments | « no previous file | test/elemHide.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld