Comparing version 0.0.2 to 0.1.0
@@ -23,3 +23,7 @@ var css = require('css'); | ||
var conditions = filtered.shift().nodes.filter(function (subnode) { | ||
return ['spacing'].indexOf(subnode.type) === -1; | ||
if (subnode.type === 'spacing') { | ||
subnode.type = 'child'; | ||
delete subnode.value; | ||
} | ||
return subnode; | ||
}); | ||
@@ -26,0 +30,0 @@ |
{ | ||
"name": "cssplexity", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "A small helper to calculcate the cyclomatic complexity of CSS selectors", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -68,2 +68,4 @@ # CSSplexity | ||
* 0.1.0 | ||
* Fix complexity calculation to include child selectors as well | ||
* 0.0.2 | ||
@@ -70,0 +72,0 @@ * Update outdated dependencies |
[{ | ||
"complexity": 3, | ||
"complexity": 6, | ||
"selector": ".grid-homepage .teaser .article-title .headline" | ||
}, { | ||
"complexity": 3, | ||
"complexity": 6, | ||
"selector": ".grid-homepage .teaser .article-title .headline-intro" | ||
@@ -7,0 +7,0 @@ }, { |
[{ | ||
"complexity": 4, | ||
"complexity": 7, | ||
"selector": ".grid-homepage .teaser .article-title .headline[data-tooltip*=\"demo\"]" | ||
}] |
[{ | ||
"complexity": 6, | ||
"complexity": 7, | ||
"selector": "a#content.active > div::first-line [data-content]" | ||
@@ -4,0 +4,0 @@ }, { |
@@ -21,3 +21,3 @@ var fs = require('fs'); | ||
tap.equal(cssplexity.selector('body'), 0); | ||
tap.equal(cssplexity.selector('.grid-homepage .teaser .article-title .headline'), 3); | ||
tap.equal(cssplexity.selector('.grid-homepage .teaser .article-title .headline'), 6); | ||
tap.equal(cssplexity.selector(new Array(3).join(' ')), false); | ||
@@ -53,12 +53,18 @@ | ||
type: 'class', | ||
'name': 'headline' | ||
name: 'headline' | ||
}, { | ||
type: 'child' | ||
}, { | ||
type: 'class', | ||
'name': 'article-title' | ||
name: 'article-title' | ||
}, { | ||
type: 'child' | ||
}, { | ||
type: 'class', | ||
'name': 'teaser' | ||
name: 'teaser' | ||
}, { | ||
type: 'child' | ||
}, { | ||
type: 'class', | ||
'name': 'grid-homepage' | ||
name: 'grid-homepage' | ||
}]); | ||
@@ -74,3 +80,3 @@ | ||
type: 'class', | ||
'name': 'headline' | ||
name: 'headline' | ||
}); | ||
@@ -85,10 +91,16 @@ | ||
tap.deepEqual(cssplexity.conditions('.grid-homepage .teaser .article-title .headline'), [{ | ||
type: 'child' | ||
}, { | ||
type: 'class', | ||
'name': 'article-title' | ||
name: 'article-title' | ||
}, { | ||
type: 'child' | ||
}, { | ||
type: 'class', | ||
'name': 'teaser' | ||
name: 'teaser' | ||
}, { | ||
type: 'child' | ||
}, { | ||
type: 'class', | ||
'name': 'grid-homepage' | ||
name: 'grid-homepage' | ||
}]); |
9873
213
81