Skip to content

Commit 39e20ba

Browse files
author
Nicholas C. Zakas
committed
Ensure text-indent rule doesn't throw an error (fixes #179)
1 parent 199090c commit 39e20ba

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/rules/text-indent.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ CSSLint.addRule({
2727
//event handler for end of rules
2828
function endRule(event){
2929
if (textIndent){
30-
reporter.warn("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set text-direction for that item to ltr.", name.line, name.col, rule);
30+
reporter.warn("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set text-direction for that item to ltr.", textIndent.line, textIndent.col, rule);
3131
}
3232
}
3333

@@ -37,10 +37,10 @@ CSSLint.addRule({
3737
//check for use of "font-size"
3838
parser.addListener("property", function(event){
3939
var name = event.property.toString().toLowerCase(),
40-
value = event.value.parts[0].value;
40+
value = event.value;
4141

42-
if (name == "text-indent" && value < -99){
43-
textIndent = true;
42+
if (name == "text-indent" && value.parts[0].value < -99){
43+
textIndent = event.property;
4444
} else if (name == "direction" && value == "ltr"){
4545
textIndent = false;
4646
}

tests/rules/text-indent.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
"5px text-indent should not result in a warning": function(){
2828
var result = CSSLint.verify(".foo{text-indent: 5px;}", {"text-indent": 1 });
2929
Assert.areEqual(0, result.messages.length);
30+
},
31+
32+
"This should cause a warning, not an error": function(){
33+
var result = CSSLint.verify(".top h1 a { background: url(../images/background/logo.png) no-repeat; display: block; height: 44px; position: relative; text-indent: -9999px; width: 250px; }", { "text-indent": 1 });
34+
Assert.areEqual(1, result.messages.length);
35+
Assert.areEqual("warning", result.messages[0].type);
36+
Assert.areEqual("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set text-direction for that item to ltr.", result.messages[0].message);
3037
}
3138

3239
}));

0 commit comments

Comments
 (0)