Skip to content

Commit

Permalink
Merge pull request #13 from sawa-zen/fix/tabindex
Browse files Browse the repository at this point in the history
fix: patch tabindex rule
  • Loading branch information
maranran committed May 20, 2019
2 parents 0c182d9 + cac30a4 commit 70c91ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/rules/tabindex-no-positive.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,9 @@ module.exports = {
create (context) {
return VueUtils.defineTemplateBodyVisitor(context, {
"VAttribute" (node) {
let tabindex;
if (node.directive) {
tabindex = node.key.argument.name === 'tabindex';
} else {
tabindex = node.key.name === 'tabindex';
}

if (!tabindex) {
const isTabindex = (!node.directive && node.key.name === 'tabindex')
|| (node.key.name.name === 'bind' && node.key.argument.name === 'tabindex')
if (!isTabindex) {
return;
}

Expand Down
4 changes: 4 additions & 0 deletions tests/lib/rules/tabindex-no-positive.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ tester.run('tabindex-no-positive', rule, {
filename: 'test.vue',
code: '<template><span tabindex="0"></span></template>',
},
{
filename: 'test.vue',
code: '<template><span v-if="true" tabindex="0"></span></template>',
},
{
filename: 'test.vue',
code: '<template><span tabindex="-1"></span></template>',
Expand Down

0 comments on commit 70c91ac

Please sign in to comment.