Skip to content

Commit 73ee863

Browse files
committed
Merge pull request #311 from mattiacci/gradients
Microsoft uses unprefixed gradients
2 parents 43cee88 + 80fe135 commit 73ee863

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

src/rules/gradients.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ CSSLint.addRule({
2020
moz: 0,
2121
webkit: 0,
2222
oldWebkit: 0,
23-
ms: 0,
2423
o: 0
2524
};
2625
});
2726

2827
parser.addListener("property", function(event){
2928

30-
if (/\-(moz|ms|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)){
29+
if (/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)){
3130
gradients[RegExp.$1] = 1;
3231
} else if (/\-webkit\-gradient/i.test(event.value)){
3332
gradients.oldWebkit = 1;
@@ -50,20 +49,16 @@ CSSLint.addRule({
5049
missing.push("Old Webkit (Safari 4+, Chrome)");
5150
}
5251

53-
if (!gradients.ms){
54-
missing.push("Internet Explorer 10+");
55-
}
56-
5752
if (!gradients.o){
5853
missing.push("Opera 11.1+");
5954
}
6055

61-
if (missing.length && missing.length < 5){
56+
if (missing.length && missing.length < 4){
6257
reporter.report("Missing vendor-prefixed CSS gradients for " + missing.join(", ") + ".", event.selectors[0].line, event.selectors[0].col, rule);
6358
}
6459

6560
});
6661

6762
}
6863

69-
});
64+
});

tests/rules/gradients.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ background: -moz-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 );
1010
background: -webkit-gradient(linear, left top, left bottom, color-stop(,#1e5799), color-stop(,#2989d8), color-stop(,#207cca), color-stop(10,#7db9e8));
1111
background: -webkit-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
1212
background: -o-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
13-
background: -ms-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
1413
1514
*/
1615

@@ -20,39 +19,32 @@ background: -ms-linear-gradient(top, #1e5799 ,#2989d8 ,#207cca ,#7db9e8 );
2019
var result = CSSLint.verify(".foo { background: -moz-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
2120
Assert.areEqual(1, result.messages.length);
2221
Assert.areEqual("warning", result.messages[0].type);
23-
Assert.areEqual("Missing vendor-prefixed CSS gradients for Webkit (Safari 5+, Chrome), Old Webkit (Safari 4+, Chrome), Internet Explorer 10+, Opera 11.1+.", result.messages[0].message);
22+
Assert.areEqual("Missing vendor-prefixed CSS gradients for Webkit (Safari 5+, Chrome), Old Webkit (Safari 4+, Chrome), Opera 11.1+.", result.messages[0].message);
2423
},
2524

2625
"Only using Opera gradients should result in a warning": function(){
2726
var result = CSSLint.verify(".foo { background: -o-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
2827
Assert.areEqual(1, result.messages.length);
2928
Assert.areEqual("warning", result.messages[0].type);
30-
Assert.areEqual("Missing vendor-prefixed CSS gradients for Firefox 3.6+, Webkit (Safari 5+, Chrome), Old Webkit (Safari 4+, Chrome), Internet Explorer 10+.", result.messages[0].message);
31-
},
32-
33-
"Only using IE gradients should result in a warning": function(){
34-
var result = CSSLint.verify(".foo { background: -ms-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
35-
Assert.areEqual(1, result.messages.length);
36-
Assert.areEqual("warning", result.messages[0].type);
37-
Assert.areEqual("Missing vendor-prefixed CSS gradients for Firefox 3.6+, Webkit (Safari 5+, Chrome), Old Webkit (Safari 4+, Chrome), Opera 11.1+.", result.messages[0].message);
29+
Assert.areEqual("Missing vendor-prefixed CSS gradients for Firefox 3.6+, Webkit (Safari 5+, Chrome), Old Webkit (Safari 4+, Chrome).", result.messages[0].message);
3830
},
3931

4032
"Only using WebKit gradients should result in a warning": function(){
4133
var result = CSSLint.verify(".foo { background: -webkit-linear-gradient(top, #1e5799 , #2989d8 , #207cca , #7db9e8 ); }", {"gradients": 1 });
4234
Assert.areEqual(1, result.messages.length);
4335
Assert.areEqual("warning", result.messages[0].type);
44-
Assert.areEqual("Missing vendor-prefixed CSS gradients for Firefox 3.6+, Old Webkit (Safari 4+, Chrome), Internet Explorer 10+, Opera 11.1+.", result.messages[0].message);
36+
Assert.areEqual("Missing vendor-prefixed CSS gradients for Firefox 3.6+, Old Webkit (Safari 4+, Chrome), Opera 11.1+.", result.messages[0].message);
4537
},
4638

4739
"Only using old WebKit gradients should result in a warning": function(){
4840
var result = CSSLint.verify(".foo { background: -webkit-gradient(linear, left top, left bottom, color-stop(10%,#1e5799), color-stop(20%,#2989d8), color-stop(30%,#207cca), color-stop(100%,#7db9e8)); }", {"gradients": 1 });
4941
Assert.areEqual(1, result.messages.length);
5042
Assert.areEqual("warning", result.messages[0].type);
51-
Assert.areEqual("Missing vendor-prefixed CSS gradients for Firefox 3.6+, Webkit (Safari 5+, Chrome), Internet Explorer 10+, Opera 11.1+.", result.messages[0].message);
43+
Assert.areEqual("Missing vendor-prefixed CSS gradients for Firefox 3.6+, Webkit (Safari 5+, Chrome), Opera 11.1+.", result.messages[0].message);
5244
},
5345

5446
"Using all vendor-prefixed gradients should not result in a warning": function(){
55-
var result = CSSLint.verify("div.box {\n background: -moz-linear-gradient(top, #1e5799 0%, #7db9e8 100%);\n background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color- stop(100%,#7db9e8));\n background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 100%);\n background: -o-linear-gradient(top, #1e5799 0%,#7db9e8 100%);\n background: -ms-linear-gradient(top, #1e5799 0%,#7db9e8 100%); \n}", { "gradients": 1 });
47+
var result = CSSLint.verify("div.box {\n background: -moz-linear-gradient(top, #1e5799 0%, #7db9e8 100%);\n background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color- stop(100%,#7db9e8));\n background: -webkit-linear-gradient(top, #1e5799 0%,#7db9e8 100%);\n background: -o-linear-gradient(top, #1e5799 0%,#7db9e8 100%);\n}", { "gradients": 1 });
5648
Assert.areEqual(0, result.messages.length);
5749
}
5850
}));

0 commit comments

Comments
 (0)