Skip to content

Commit

Permalink
adds strict mode for node < 6 consts in for loops. removes unused sel…
Browse files Browse the repository at this point in the history
…ectors set.
  • Loading branch information
jonatanpedersen committed Feb 4, 2017
1 parent 6d7e128 commit 2ffaa8e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use strict';
const css = require('css');
const htmlparser = require('htmlparser2');
const CssSelectorParser = require('css-selector-parser').CssSelectorParser;
Expand All @@ -20,7 +21,6 @@ function getSelectorRulesFromCssAst(cssAst) {
cssSelectorParser.registerNestingOperators('>', '+', '~');
cssSelectorParser.registerAttrEqualityMods('^', '$', '*', '~');

const selectors = new Set();
const selectorRules = [];

walk(cssAst.stylesheet);
Expand All @@ -30,17 +30,15 @@ function getSelectorRulesFromCssAst(cssAst) {
function walk(node) {
for (var j = 0; j < node.rules.length; j++) {
const rule = node.rules[j];

if (rule.type === 'rule' && rule.selectors) {
if (rule.type === 'rule') {
for (var i = 0; i < rule.selectors.length; i++) {
const selector = rule.selectors[i];

selectorRules.push({
selector: selector,
rule: cssSelectorParser.parse(selector).rule
rule: cssSelectorParser.parse(selector)
});

selectors.add(selector);
}
} else if (rule.type === 'media') {
walk(rule);
Expand Down

0 comments on commit 2ffaa8e

Please sign in to comment.