Skip to content

Commit

Permalink
fix line and column numbers for compatible vendor prefixes rule (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Feb 10, 2012
1 parent 151a0eb commit 66c1baa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/rules/compatible-vendor-prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ CSSLint.addRule({
});

parser.addListener("property", function (event) {
var name = event.property.text;
if (CSSLint.Util.indexOf(applyTo, name) > -1) {
var name = event.property;
if (CSSLint.Util.indexOf(applyTo, name.text) > -1) {
properties.push(name);
}
});
Expand Down Expand Up @@ -131,15 +131,17 @@ CSSLint.addRule({
for (prop in compatiblePrefixes) {
if (compatiblePrefixes.hasOwnProperty(prop)) {
variations = compatiblePrefixes[prop];
if (CSSLint.Util.indexOf(variations, name) > -1) {
if (propertyGroups[prop] === undefined) {
if (CSSLint.Util.indexOf(variations, name.text) > -1) {
if (!propertyGroups[prop]) {
propertyGroups[prop] = {
full : variations.slice(0),
actual : []
actual : [],
actualNodes: []
};
}
if (CSSLint.Util.indexOf(propertyGroups[prop].actual, name) === -1) {
propertyGroups[prop].actual.push(name);
if (CSSLint.Util.indexOf(propertyGroups[prop].actual, name.text) === -1) {
propertyGroups[prop].actual.push(name.text);
propertyGroups[prop].actualNodes.push(name);
}
}
}
Expand All @@ -157,7 +159,7 @@ CSSLint.addRule({
item = full[i];
if (CSSLint.Util.indexOf(actual, item) === -1) {
propertiesSpecified = (actual.length === 1) ? actual[0] : (actual.length == 2) ? actual.join(" and ") : actual.join(", ");
reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", event.selectors[0].line, event.selectors[0].col, rule);
reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", value.actualNodes[0].line, value.actualNodes[0].col, rule);
}
}

Expand Down
7 changes: 7 additions & 0 deletions tests/rules/compatible-vendor-prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,22 @@
Assert.areEqual(1, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("The property -moz-border-radius is compatible with -webkit-border-radius and should be included as well.", result.messages[0].message);
Assert.areEqual(6, result.messages[0].col);
Assert.areEqual(1, result.messages[0].line);
},

"Using -webkit-transition and -moz-transition should warn to also include -o-transition and -ms-transition.": function(){
var result = CSSLint.verify("h1 { -webkit-transition: height 20px 1s; -moz-transition: height 20px 1s; }", { "compatible-vendor-prefixes": 1 });
Assert.areEqual(2, result.messages.length);
Assert.areEqual("warning", result.messages[0].type);
Assert.areEqual("The property -o-transition is compatible with -webkit-transition and -moz-transition and should be included as well.", result.messages[0].message);
Assert.areEqual(6, result.messages[0].col);
Assert.areEqual(1, result.messages[0].line);
Assert.areEqual("warning", result.messages[1].type);
Assert.areEqual("The property -ms-transition is compatible with -webkit-transition and -moz-transition and should be included as well.", result.messages[1].message);
Assert.areEqual(6, result.messages[1].col);
Assert.areEqual(1, result.messages[1].line);

},

"Using -webkit-transform should warn to also include -moz-transform, -ms-transform, and -o-transform.": function(){
Expand Down

0 comments on commit 66c1baa

Please sign in to comment.