From 9937670a2e0516435af9eba76e209b96dd56818e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Mon, 27 Oct 2014 16:57:51 +0100 Subject: [PATCH] Add rules for cssComplexSelectorsByAttribute and cssDuplicatedProperties --- app/node_views/results.html | 37 ++++++++++++++++++++++++++++++- app/public/scripts/resultsCtrl.js | 4 +++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/node_views/results.html b/app/node_views/results.html index 3113b2c..879a17e 100644 --- a/app/node_views/results.html +++ b/app/node_views/results.html @@ -310,6 +310,28 @@ +
+
Complex attributes selector
+
+ {{phantomasResults.metrics.cssComplexSelectorsByAttribute}} + +
+
+
+ +

Complex attributes selectors are one of these: +

    +
  • .foo[type*=bar] (contains bar)
  • +
  • .foo[type^=bar] (starts with bar)
  • +
  • .foo[type|=bar] (starts with bar or bar-)
  • +
  • .foo[type$=bar] (ends with bar)
  • +
  • .foo[type~=bar baz] (bar or baz)
  • +
+

+

Their matching process needs more CPU and it has a cost on performances.

+
+
+
@@ -346,7 +368,7 @@ -
+
Duplicated selectors
{{phantomasResults.metrics.cssDuplicatedSelectors}} @@ -359,6 +381,19 @@
+
+
Duplicated properties
+
+ {{phantomasResults.metrics.cssDuplicatedProperties}} + +
+
+
+ +

This is the number of property definitions duplicated within a selector.

+
+
+
Empty rules
diff --git a/app/public/scripts/resultsCtrl.js b/app/public/scripts/resultsCtrl.js index 26248a2..d8c9aaf 100644 --- a/app/public/scripts/resultsCtrl.js +++ b/app/public/scripts/resultsCtrl.js @@ -296,7 +296,8 @@ app.controller('ResultsCtrl', function ($scope) { var note = 'A'; var score = $scope.phantomasResults.metrics.cssRules + - $scope.phantomasResults.metrics.cssComplexSelectors * 5; + $scope.phantomasResults.metrics.cssComplexSelectors * 5 + + $scope.phantomasResults.metrics.cssComplexSelectorsByAttribute * 15; if (score > 500) { note = 'B'; } @@ -324,6 +325,7 @@ app.controller('ResultsCtrl', function ($scope) { var note = 'A'; var score = $scope.phantomasResults.metrics.cssDuplicatedSelectors + + $scope.phantomasResults.metrics.cssDuplicatedProperties + $scope.phantomasResults.metrics.cssEmptyRules + $scope.phantomasResults.metrics.cssExpressions * 10 + $scope.phantomasResults.metrics.cssImportants * 2 +