Created
March 8, 2012 16:09
-
-
Save DavidSouther/2001793 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Calculate the specificity of a selectorList (the sum of the count of | |
* matching attributes). | |
*/ | |
var specificity = function(selectorList) { | |
var spec = 0; | |
goog.array.forEach(selectorList, function(selector){ | |
spec += selector.hierarchy?1:0; | |
spec += selector.type?1:0; | |
spec += selector.id?1:0; | |
spec += selector.attributes.length; | |
}); | |
return spec; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment