Comparing version 0.0.2 to 0.0.3
@@ -22,3 +22,3 @@ | ||
exports.version = '0.0.2'; | ||
exports.version = '0.0.3'; | ||
@@ -25,0 +25,0 @@ /** |
@@ -34,41 +34,45 @@ | ||
Selector.prototype.specificity = function () { | ||
if (this.spec) return this.spec; | ||
if (!this.spec) return specificity(this.text); | ||
return this.spec; | ||
var parsed = parse(this.text) | ||
, expressions = parsed.expressions[0] | ||
, spec = [0, 0, 0, 0] | ||
, nots = [] | ||
function specificity (text) { | ||
var parsed = parse(text) | ||
, expressions = parsed.expressions[0] | ||
, spec = [0, 0, 0, 0] | ||
, nots = [] | ||
for (var i = 0; i < expressions.length; i++) { | ||
var expression = expressions[i], pseudos = expression.pseudos; | ||
for (var i = 0; i < expressions.length; i++) { | ||
var expression = expressions[i] | ||
, pseudos = expression.pseudos | ||
// id awards a point in the second column | ||
if (expression.id) spec[1]++; | ||
// id awards a point in the second column | ||
if (expression.id) spec[1]++; | ||
// classes and attributes award a point each in the third column | ||
if (expression.attributes) spec[2] += expression.attributes.length; | ||
if (expression.classes) spec[2] += expression.classes.length; | ||
// classes and attributes award a point each in the third column | ||
if (expression.attributes) spec[2] += expression.attributes.length; | ||
if (expression.classes) spec[2] += expression.classes.length; | ||
// tag awards a point in the fourth column | ||
if (expression.tag && expression.tag != '*') spec[3]++; | ||
// tag awards a point in the fourth column | ||
if (expression.tag && expression.tag != '*') spec[3]++; | ||
// pseudos award a point each in the fourth column | ||
if (pseudos) { | ||
spec[3] += pseudos.length; | ||
// pseudos award a point each in the fourth column | ||
if (pseudos) { | ||
spec[3] += pseudos.length; | ||
for (var p = 0; p < pseudos.length; p++) { | ||
if (pseudos[p].key == 'not'){ | ||
nots.push(pseudos[p].value); | ||
spec[3]--; | ||
for (var p = 0; p < pseudos.length; p++) { | ||
if (pseudos[p].key == 'not'){ | ||
nots.push(pseudos[p].value); | ||
spec[3]--; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
for (var ii = nots.length; ii--;) { | ||
var not = specificity(nots[ii]); | ||
for (var jj = 4; jj--;) spec[jj] += not[jj]; | ||
for (var ii = nots.length; ii--;) { | ||
var not = specificity(nots[ii]); | ||
for (var jj = 4; jj--;) spec[jj] += not[jj]; | ||
} | ||
return spec; | ||
} | ||
return this.spec = spec; | ||
} |
{ | ||
"name": "juice" | ||
, "version": "0.0.2" | ||
, "version": "0.0.3" | ||
, "description": "Inlines css into html source" | ||
, "contributors": [ | ||
{ "name": "Guillermo Rauch", "email": "guillermo@learnboost.com" } | ||
, { "name": "Arian Stolwijk", "email": "arian@aryweb.nl" } | ||
] | ||
, "devDependencies": { | ||
@@ -6,0 +10,0 @@ "should": "0.3.1" |
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
8571
11
297
1