Skip to content

Commit 85e9ed9

Browse files
committed
tabindex-no-positive
1 parent 915c183 commit 85e9ed9

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/validate/html/a11y.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ export default function a11y(
7878
validator.warn(`A11y: The scope attribute should only be used with <th> elements`, attribute.start);
7979
}
8080

81+
// tabindex-no-positive
82+
if (name === 'tabindex') {
83+
const value = getStaticAttributeValue(node, 'tabindex');
84+
if (!isNaN(value) && +value > 0) {
85+
validator.warn(`A11y: avoid tabindex values above zero`, attribute.start);
86+
}
87+
}
88+
8189
attributeMap.set(attribute.name, attribute);
8290
});
8391

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div tabindex='-1'/>
2+
<div tabindex='0'/>
3+
<div tabindex='1'/>
4+
<div tabindex='{{foo}}'/>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"message": "A11y: avoid tabindex values above zero",
4+
"loc": {
5+
"line": 3,
6+
"column": 5
7+
},
8+
"pos": 46
9+
}
10+
]

0 commit comments

Comments
 (0)