Skip to content

Commit 170ca18

Browse files
committed
final clean up
1 parent b793408 commit 170ca18

File tree

3 files changed

+15
-117
lines changed

3 files changed

+15
-117
lines changed

Recipe.min.js

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,6 @@ void function() { try {
834834

835835
if(rule.cssRules) {
836836
CSSUsage.PropertyValuesAnalyzer.anaylzeStyleOfRulePropCount(rule, selectedAtruleUsage);
837-
processNestedAtRules(rule.cssRules, selectedAtruleUsage);
838837
}
839838

840839
processConditionText(rule.conditionText, selectedAtruleUsage.conditions);
@@ -846,9 +845,9 @@ void function() { try {
846845
* of the @atrule in question.
847846
*/
848847
function processConditionText(conditionText, selectedAtruleConditionalUsage) {
849-
conditionText = conditionText.replace(/[0-9]/g, '');
850-
conditionText = conditionText.replace(".px", "px");
851-
conditionText = conditionText.replace(".em", "px");
848+
// replace numeric specific information from condition statements
849+
conditionText = conditionText.replace(/[0-9]+.*[0-9]+/g, '');
850+
852851
if(!selectedAtruleConditionalUsage[conditionText]) {
853852
selectedAtruleConditionalUsage[conditionText] = Object.create(null);
854853
selectedAtruleConditionalUsage[conditionText] = {"count": 1}
@@ -858,41 +857,6 @@ void function() { try {
858857
}
859858
}
860859

861-
/**
862-
* This processes the usage of nested atrules within other at rules.
863-
*/
864-
function processNestedAtRules(cssRules, selectedAtruleConditionalUsage) {
865-
for(let index in cssRules) {
866-
let ruleBody = cssRules[index];
867-
868-
869-
if(!ruleBody.cssText) {
870-
continue;
871-
}
872-
873-
// only collect stats for sub atrules
874-
if(!isRuleAnAtRule(ruleBody)) {
875-
continue;
876-
}
877-
878-
var nestRuleSelector = nestRuleSelector = '@atrule:' + ruleBody.type;
879-
880-
if(!selectedAtruleConditionalUsage["nested"]) {
881-
selectedAtruleConditionalUsage["nested"] = Object.create(null);
882-
}
883-
884-
var nestedUsage = selectedAtruleConditionalUsage["nested"];
885-
886-
if(!nestedUsage[nestRuleSelector]) {
887-
nestedUsage[nestRuleSelector] = Object.create(null);
888-
nestedUsage[nestRuleSelector] = { "count": 1 }
889-
} else {
890-
var nestedCount = nestedUsage[nestRuleSelector].count;
891-
nestedUsage[nestRuleSelector].count = nestedCount + 1;
892-
}
893-
}
894-
}
895-
896860
/**
897861
* This will process all other @atrules that don't have conditions or styles.
898862
* [1] It will process any props and values used within the body of the rule.
@@ -916,6 +880,7 @@ void function() { try {
916880
processKeyframeAtRules(rule);
917881
} else if(CSSUsageResults.rules[selectorText].props) {
918882
atrulesUsage[selectorText].props = CSSUsageResults.rules[selectorText].props;
883+
delete atrulesUsage[selectorText].props.values;
919884
}
920885
}
921886

@@ -937,6 +902,7 @@ void function() { try {
937902
* WARN: tightly coupled with previous processing of rules.
938903
*/
939904
atrulesUsageForSelector.props = CSSUsageResults.rules["@atrule:8"].props;
905+
delete atrulesUsageForSelector.props.values;
940906

941907
for(let index in rule.cssRules) {
942908
let keyframe = rule.cssRules[index];

cssUsage.src.js

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,6 @@ void function() { try {
834834

835835
if(rule.cssRules) {
836836
CSSUsage.PropertyValuesAnalyzer.anaylzeStyleOfRulePropCount(rule, selectedAtruleUsage);
837-
processNestedAtRules(rule.cssRules, selectedAtruleUsage);
838837
}
839838

840839
processConditionText(rule.conditionText, selectedAtruleUsage.conditions);
@@ -846,9 +845,9 @@ void function() { try {
846845
* of the @atrule in question.
847846
*/
848847
function processConditionText(conditionText, selectedAtruleConditionalUsage) {
849-
conditionText = conditionText.replace(/[0-9]/g, '');
850-
conditionText = conditionText.replace(".px", "px");
851-
conditionText = conditionText.replace(".em", "px");
848+
// replace numeric specific information from condition statements
849+
conditionText = conditionText.replace(/[0-9]+.*[0-9]+/g, '');
850+
852851
if(!selectedAtruleConditionalUsage[conditionText]) {
853852
selectedAtruleConditionalUsage[conditionText] = Object.create(null);
854853
selectedAtruleConditionalUsage[conditionText] = {"count": 1}
@@ -858,41 +857,6 @@ void function() { try {
858857
}
859858
}
860859

861-
/**
862-
* This processes the usage of nested atrules within other at rules.
863-
*/
864-
function processNestedAtRules(cssRules, selectedAtruleConditionalUsage) {
865-
for(let index in cssRules) {
866-
let ruleBody = cssRules[index];
867-
868-
869-
if(!ruleBody.cssText) {
870-
continue;
871-
}
872-
873-
// only collect stats for sub atrules
874-
if(!isRuleAnAtRule(ruleBody)) {
875-
continue;
876-
}
877-
878-
var nestRuleSelector = nestRuleSelector = '@atrule:' + ruleBody.type;
879-
880-
if(!selectedAtruleConditionalUsage["nested"]) {
881-
selectedAtruleConditionalUsage["nested"] = Object.create(null);
882-
}
883-
884-
var nestedUsage = selectedAtruleConditionalUsage["nested"];
885-
886-
if(!nestedUsage[nestRuleSelector]) {
887-
nestedUsage[nestRuleSelector] = Object.create(null);
888-
nestedUsage[nestRuleSelector] = { "count": 1 }
889-
} else {
890-
var nestedCount = nestedUsage[nestRuleSelector].count;
891-
nestedUsage[nestRuleSelector].count = nestedCount + 1;
892-
}
893-
}
894-
}
895-
896860
/**
897861
* This will process all other @atrules that don't have conditions or styles.
898862
* [1] It will process any props and values used within the body of the rule.
@@ -916,6 +880,7 @@ void function() { try {
916880
processKeyframeAtRules(rule);
917881
} else if(CSSUsageResults.rules[selectorText].props) {
918882
atrulesUsage[selectorText].props = CSSUsageResults.rules[selectorText].props;
883+
delete atrulesUsage[selectorText].props.values;
919884
}
920885
}
921886

@@ -937,6 +902,7 @@ void function() { try {
937902
* WARN: tightly coupled with previous processing of rules.
938903
*/
939904
atrulesUsageForSelector.props = CSSUsageResults.rules["@atrule:8"].props;
905+
delete atrulesUsageForSelector.props.values;
940906

941907
for(let index in rule.cssRules) {
942908
let keyframe = rule.cssRules[index];

src/cssUsage.js

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ void function() { try {
337337

338338
if(rule.cssRules) {
339339
CSSUsage.PropertyValuesAnalyzer.anaylzeStyleOfRulePropCount(rule, selectedAtruleUsage);
340-
processNestedAtRules(rule.cssRules, selectedAtruleUsage);
341340
}
342341

343342
processConditionText(rule.conditionText, selectedAtruleUsage.conditions);
@@ -349,9 +348,9 @@ void function() { try {
349348
* of the @atrule in question.
350349
*/
351350
function processConditionText(conditionText, selectedAtruleConditionalUsage) {
352-
conditionText = conditionText.replace(/[0-9]/g, '');
353-
conditionText = conditionText.replace(".px", "px");
354-
conditionText = conditionText.replace(".em", "px");
351+
// replace numeric specific information from condition statements
352+
conditionText = conditionText.replace(/[0-9]+.*[0-9]+/g, '');
353+
355354
if(!selectedAtruleConditionalUsage[conditionText]) {
356355
selectedAtruleConditionalUsage[conditionText] = Object.create(null);
357356
selectedAtruleConditionalUsage[conditionText] = {"count": 1}
@@ -361,41 +360,6 @@ void function() { try {
361360
}
362361
}
363362

364-
/**
365-
* This processes the usage of nested atrules within other at rules.
366-
*/
367-
function processNestedAtRules(cssRules, selectedAtruleConditionalUsage) {
368-
for(let index in cssRules) {
369-
let ruleBody = cssRules[index];
370-
371-
372-
if(!ruleBody.cssText) {
373-
continue;
374-
}
375-
376-
// only collect stats for sub atrules
377-
if(!isRuleAnAtRule(ruleBody)) {
378-
continue;
379-
}
380-
381-
var nestRuleSelector = nestRuleSelector = '@atrule:' + ruleBody.type;
382-
383-
if(!selectedAtruleConditionalUsage["nested"]) {
384-
selectedAtruleConditionalUsage["nested"] = Object.create(null);
385-
}
386-
387-
var nestedUsage = selectedAtruleConditionalUsage["nested"];
388-
389-
if(!nestedUsage[nestRuleSelector]) {
390-
nestedUsage[nestRuleSelector] = Object.create(null);
391-
nestedUsage[nestRuleSelector] = { "count": 1 }
392-
} else {
393-
var nestedCount = nestedUsage[nestRuleSelector].count;
394-
nestedUsage[nestRuleSelector].count = nestedCount + 1;
395-
}
396-
}
397-
}
398-
399363
/**
400364
* This will process all other @atrules that don't have conditions or styles.
401365
* [1] It will process any props and values used within the body of the rule.
@@ -419,6 +383,7 @@ void function() { try {
419383
processKeyframeAtRules(rule);
420384
} else if(CSSUsageResults.rules[selectorText].props) {
421385
atrulesUsage[selectorText].props = CSSUsageResults.rules[selectorText].props;
386+
delete atrulesUsage[selectorText].props.values;
422387
}
423388
}
424389

@@ -440,6 +405,7 @@ void function() { try {
440405
* WARN: tightly coupled with previous processing of rules.
441406
*/
442407
atrulesUsageForSelector.props = CSSUsageResults.rules["@atrule:8"].props;
408+
delete atrulesUsageForSelector.props.values;
443409

444410
for(let index in rule.cssRules) {
445411
let keyframe = rule.cssRules[index];

0 commit comments

Comments
 (0)