Skip to content

Commit 5468413

Browse files
committed
Merge pull request #206 from ideadapt/feature/invalid-pseudo-selector-error
Throw SyntaxError if pseudo selector is invalid
2 parents 69f966e + 721e8d6 commit 5468413

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/css/Parser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,10 @@ Parser.prototype = function(){
15751575

15761576
if (pseudo){
15771577
pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col);
1578+
}else{
1579+
var startLine = tokenStream.LT(1).startLine,
1580+
startCol = tokenStream.LT(0).startCol;
1581+
throw new SyntaxError("Expected a `FUNCTION` or `IDENT` after colon at line " + startLine + ", col " + startCol + ".", startLine, startCol);
15781582
}
15791583
}
15801584

tests/css/Parser.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,17 @@ var YUITest = require("yuitest"),
444444

445445
name: "Pseudo Class Selector Tests",
446446

447+
_should: {
448+
error: {
449+
testInvalidPseudoClassSelector: "Expected a `FUNCTION` or `IDENT` after colon at line 1, col 2."
450+
}
451+
},
452+
453+
testInvalidPseudoClassSelector: function(){
454+
var parser = new Parser();
455+
parser.parseSelector("a:");
456+
},
457+
447458
testSimplePseudoClassSelector: function(){
448459
var parser = new Parser();
449460
var result = parser.parseSelector("a:hover");

0 commit comments

Comments
 (0)