| 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) |
| { |