Skip to content

Commit 5ff70e2

Browse files
committed
removed nested rules usage data
1 parent 8d17d7d commit 5ff70e2

File tree

3 files changed

+3
-171
lines changed

3 files changed

+3
-171
lines changed

Recipe.min.js

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,6 @@ void function() { try {
824824
atrulesUsage[selectorText] = Object.create(null);
825825
atrulesUsage[selectorText] = {"count": 1,
826826
"props": {},
827-
"nested": {},
828827
"conditions": {}}
829828
} else {
830829
var count = atrulesUsage[selectorText].count;
@@ -835,66 +834,11 @@ void function() { try {
835834

836835
if(rule.cssRules) {
837836
CSSUsage.PropertyValuesAnalyzer.anaylzeStyleOfRulePropCount(rule, selectedAtruleUsage);
838-
processNestedRules(rule, selectedAtruleUsage.nested);
839837
}
840838

841839
processConditionText(rule.conditionText, selectedAtruleUsage.conditions);
842840
}
843841

844-
/**
845-
* Analyzes the given @atrules, such as @supports, and counts the usage of the nested rules
846-
* according to their type. NOTE: must pass in the current usage of nested rules for the
847-
* given @atrule.
848-
*/
849-
function processNestedRules(rule, nestedRulesUsage) {
850-
// find the rule count for nested rules
851-
for(let index in rule.cssRules) {
852-
let ruleBody = rule.cssRules[index];
853-
854-
if(!ruleBody.cssText) {
855-
continue;
856-
}
857-
858-
var nestRuleSelector;
859-
860-
if(isRuleAnAtRule(ruleBody)) {
861-
nestRuleSelector = '@atrule:' + ruleBody.type;
862-
863-
} else if(ruleBody.style) {
864-
if(ruleBody.selectorText) {
865-
try {
866-
var selectorText = CSSUsage.PropertyValuesAnalyzer.cleanSelectorText(ruleBody.selectorText);
867-
var matchedElements = [].slice.call(document.querySelectorAll(selectorText));
868-
869-
if(matchedElements.length == 0) {
870-
continue;
871-
}
872-
873-
var cleanedSelector = CSSUsage.PropertyValuesAnalyzer.generalizedSelectorsOf(selectorText);
874-
nestRuleSelector = cleanedSelector[0]; // only passed in one selector to a function that returns many
875-
} catch (ex) {
876-
continue;
877-
}
878-
}
879-
}
880-
881-
if(nestRuleSelector) {
882-
var individualNested = nestRuleSelector.split(' ');
883-
884-
for (let selector of individualNested) {
885-
if(!nestedRulesUsage[selector]) {
886-
nestedRulesUsage[selector] = Object.create(null);
887-
nestedRulesUsage[selector] = {"count": 1}
888-
} else {
889-
var nestedCount = nestedRulesUsage[selector].count;
890-
nestedRulesUsage[selector].count = nestedCount + 1;
891-
}
892-
}
893-
}
894-
}
895-
896-
}
897-
898842
/**
899843
* This processes the usage of conditions of conditional @atrules like @media.
900844
* Requires the condition of the rule to process and the current recorded usage
@@ -1538,7 +1482,7 @@ void function() { try {
15381482
propsForSelectedAtrule[normalizedKey] = {"count": 1};
15391483
} else {
15401484
var propCount = propsForSelectedAtrule[normalizedKey].count;
1541-
propCount = propCount++;
1485+
propsForSelectedAtrule[normalizedKey].count = propCount + 1;
15421486
}
15431487
}
15441488
}

cssUsage.src.js

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,6 @@ void function() { try {
824824
atrulesUsage[selectorText] = Object.create(null);
825825
atrulesUsage[selectorText] = {"count": 1,
826826
"props": {},
827-
"nested": {},
828827
"conditions": {}}
829828
} else {
830829
var count = atrulesUsage[selectorText].count;
@@ -835,66 +834,11 @@ void function() { try {
835834

836835
if(rule.cssRules) {
837836
CSSUsage.PropertyValuesAnalyzer.anaylzeStyleOfRulePropCount(rule, selectedAtruleUsage);
838-
processNestedRules(rule, selectedAtruleUsage.nested);
839837
}
840838

841839
processConditionText(rule.conditionText, selectedAtruleUsage.conditions);
842840
}
843841

844-
/**
845-
* Analyzes the given @atrules, such as @supports, and counts the usage of the nested rules
846-
* according to their type. NOTE: must pass in the current usage of nested rules for the
847-
* given @atrule.
848-
*/
849-
function processNestedRules(rule, nestedRulesUsage) {
850-
// find the rule count for nested rules
851-
for(let index in rule.cssRules) {
852-
let ruleBody = rule.cssRules[index];
853-
854-
if(!ruleBody.cssText) {
855-
continue;
856-
}
857-
858-
var nestRuleSelector;
859-
860-
if(isRuleAnAtRule(ruleBody)) {
861-
nestRuleSelector = '@atrule:' + ruleBody.type;
862-
863-
} else if(ruleBody.style) {
864-
if(ruleBody.selectorText) {
865-
try {
866-
var selectorText = CSSUsage.PropertyValuesAnalyzer.cleanSelectorText(ruleBody.selectorText);
867-
var matchedElements = [].slice.call(document.querySelectorAll(selectorText));
868-
869-
if(matchedElements.length == 0) {
870-
continue;
871-
}
872-
873-
var cleanedSelector = CSSUsage.PropertyValuesAnalyzer.generalizedSelectorsOf(selectorText);
874-
nestRuleSelector = cleanedSelector[0]; // only passed in one selector to a function that returns many
875-
} catch (ex) {
876-
continue;
877-
}
878-
}
879-
}
880-
881-
if(nestRuleSelector) {
882-
var individualNested = nestRuleSelector.split(' ');
883-
884-
for (let selector of individualNested) {
885-
if(!nestedRulesUsage[selector]) {
886-
nestedRulesUsage[selector] = Object.create(null);
887-
nestedRulesUsage[selector] = {"count": 1}
888-
} else {
889-
var nestedCount = nestedRulesUsage[selector].count;
890-
nestedRulesUsage[selector].count = nestedCount + 1;
891-
}
892-
}
893-
}
894-
}
895-
896-
}
897-
898842
/**
899843
* This processes the usage of conditions of conditional @atrules like @media.
900844
* Requires the condition of the rule to process and the current recorded usage
@@ -1538,7 +1482,7 @@ void function() { try {
15381482
propsForSelectedAtrule[normalizedKey] = {"count": 1};
15391483
} else {
15401484
var propCount = propsForSelectedAtrule[normalizedKey].count;
1541-
propCount = propCount++;
1485+
propsForSelectedAtrule[normalizedKey].count = propCount + 1;
15421486
}
15431487
}
15441488
}

src/cssUsage.js

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ void function() { try {
327327
atrulesUsage[selectorText] = Object.create(null);
328328
atrulesUsage[selectorText] = {"count": 1,
329329
"props": {},
330-
"nested": {},
331330
"conditions": {}}
332331
} else {
333332
var count = atrulesUsage[selectorText].count;
@@ -338,66 +337,11 @@ void function() { try {
338337

339338
if(rule.cssRules) {
340339
CSSUsage.PropertyValuesAnalyzer.anaylzeStyleOfRulePropCount(rule, selectedAtruleUsage);
341-
processNestedRules(rule, selectedAtruleUsage.nested);
342340
}
343341

344342
processConditionText(rule.conditionText, selectedAtruleUsage.conditions);
345343
}
346344

347-
/**
348-
* Analyzes the given @atrules, such as @supports, and counts the usage of the nested rules
349-
* according to their type. NOTE: must pass in the current usage of nested rules for the
350-
* given @atrule.
351-
*/
352-
function processNestedRules(rule, nestedRulesUsage) {
353-
// find the rule count for nested rules
354-
for(let index in rule.cssRules) {
355-
let ruleBody = rule.cssRules[index];
356-
357-
if(!ruleBody.cssText) {
358-
continue;
359-
}
360-
361-
var nestRuleSelector;
362-
363-
if(isRuleAnAtRule(ruleBody)) {
364-
nestRuleSelector = '@atrule:' + ruleBody.type;
365-
366-
} else if(ruleBody.style) {
367-
if(ruleBody.selectorText) {
368-
try {
369-
var selectorText = CSSUsage.PropertyValuesAnalyzer.cleanSelectorText(ruleBody.selectorText);
370-
var matchedElements = [].slice.call(document.querySelectorAll(selectorText));
371-
372-
if(matchedElements.length == 0) {
373-
continue;
374-
}
375-
376-
var cleanedSelector = CSSUsage.PropertyValuesAnalyzer.generalizedSelectorsOf(selectorText);
377-
nestRuleSelector = cleanedSelector[0]; // only passed in one selector to a function that returns many
378-
} catch (ex) {
379-
continue;
380-
}
381-
}
382-
}
383-
384-
if(nestRuleSelector) {
385-
var individualNested = nestRuleSelector.split(' ');
386-
387-
for (let selector of individualNested) {
388-
if(!nestedRulesUsage[selector]) {
389-
nestedRulesUsage[selector] = Object.create(null);
390-
nestedRulesUsage[selector] = {"count": 1}
391-
} else {
392-
var nestedCount = nestedRulesUsage[selector].count;
393-
nestedRulesUsage[selector].count = nestedCount + 1;
394-
}
395-
}
396-
}
397-
}
398-
399-
}
400-
401345
/**
402346
* This processes the usage of conditions of conditional @atrules like @media.
403347
* Requires the condition of the rule to process and the current recorded usage
@@ -1041,7 +985,7 @@ void function() { try {
1041985
propsForSelectedAtrule[normalizedKey] = {"count": 1};
1042986
} else {
1043987
var propCount = propsForSelectedAtrule[normalizedKey].count;
1044-
propCount = propCount++;
988+
propsForSelectedAtrule[normalizedKey].count = propCount + 1;
1045989
}
1046990
}
1047991
}

0 commit comments

Comments
 (0)