Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fix empty selector
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Apr 20, 2012
1 parent ccc7e31 commit 85a824e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions css-explain.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@
// Returns 'id', 'class', 'tag', or 'universal'.
function detectCategory(parts) {
var last = parts[parts.length-1];
if (last.match(match.ID)) {
if (!last) {
return 'universal';
} else if (last.match(match.ID)) {
return 'id';
} else if (last.match(match.CLASS)) {
return 'class';
Expand All @@ -99,8 +101,11 @@
var score = 1;
var messages = [];

if (!last) {
}

// ID category
if (last.match(match.ID)) {
else if (last.match(match.ID)) {
// Check for redundant class name
if (last.match(match.CLASS)) {
messages.push("ID is overly qualified by a class name");
Expand Down
2 changes: 2 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ exports.category = {
};

exports.specificity = function(test) {
test.deepEqual(cssExplain("").specificity, [0, 0, 0]);

test.deepEqual(cssExplain("*").specificity, [0, 0, 0]);
test.deepEqual(cssExplain("li").specificity, [0, 0, 1]);
test.deepEqual(cssExplain("li:first-line").specificity, [0, 0, 2]);
Expand Down

0 comments on commit 85a824e

Please sign in to comment.