From 2ffaa8e907b9f51f94770585fcaca84c2028d48f Mon Sep 17 00:00:00 2001 From: Jonatan Pedersen Date: Sat, 4 Feb 2017 19:21:45 +0100 Subject: [PATCH] adds strict mode for node < 6 consts in for loops. removes unused selectors set. --- index.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 6353e81..81ef84b 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +'use strict'; const css = require('css'); const htmlparser = require('htmlparser2'); const CssSelectorParser = require('css-selector-parser').CssSelectorParser; @@ -20,7 +21,6 @@ function getSelectorRulesFromCssAst(cssAst) { cssSelectorParser.registerNestingOperators('>', '+', '~'); cssSelectorParser.registerAttrEqualityMods('^', '$', '*', '~'); - const selectors = new Set(); const selectorRules = []; walk(cssAst.stylesheet); @@ -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);