-
Notifications
You must be signed in to change notification settings - Fork 476
Expand file tree
/
Copy pathnon-link-hover
More file actions
40 lines (31 loc) · 1.09 KB
/
non-link-hover
File metadata and controls
40 lines (31 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* Rule: When using a :hover selector ensure that it has been anchored with the <a> tag.
*/
/*global CSSLint*/
CSSLint.addRule({
//rule information
id: "non-link-hover",
name: "Non-Link Hover",
desc: "Using :hover pseudo-selector to non-link elements is known to be slow.",
browsers: "IE7, IE8",
//initialization
init: function(parser, reporter){
var rule = this;
parser.addListener("startrule", function(event){
var selectors = event.selectors,
selector,
part,
modifier,
i, j, k;
for (i=0; i < selectors.length; i++){
selector = selectors[i];
part = selector.parts[selector.parts.length-1];
if (part.modifiers.length-1 !== -1){
if (part.modifiers[part.modifiers.length-1].text === ":hover" && (part.elementName == null || (part.elementName != "a" && part.elementName != "A"))){
reporter.warn(rule.desc, part.line, part.col, rule);
}
}
}
});
}
});