Skip to content

Commit

Permalink
fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
maranran committed May 16, 2018
1 parent ca0da6a commit d31c71a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
26 changes: 14 additions & 12 deletions lib/rules/aria-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ module.exports = {
return VueUtils.defineTemplateBodyVisitor(context, {
"VAttribute" (node) {
const name = (!node.directive && node.key.name)
|| (node.key.name === 'bind' && node.key.argument);
const normalizedName = name.toLowerCase();
if (normalizedName.indexOf('aria-') !== 0) {
return;
|| (node.directive && node.key.name === 'bind' && node.key.argument);
if (name) {
const normalizedName = name.toLowerCase();
if (normalizedName.indexOf('aria-') !== 0) {
return;
}
const isValid = [...aria.keys()].indexOf(normalizedName) > -1;
if (isValid) {
return
}
context.report({
node,
message: `${name}: This attribute is an invalid ARIA attribute.`
});
}
const isValid = [...aria.keys()].indexOf(normalizedName) > -1;
if (isValid) {
return
}
context.report({
node,
message: `${name}: This attribute is an invalid ARIA attribute.`
});
}
}, altRule.create(context))
}
Expand Down
5 changes: 4 additions & 1 deletion tests/lib/rules/aria-role.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ tester.run('aria-role', rule, {
},
{
filename: 'test.vue',
code: '<template><Foo :role="role"></Foo></template>',
code: '<template><Foo role="maran"></Foo></template>',
options: [{
ignoreNonDOM: true
}]
},
{
code: `
Expand Down

0 comments on commit d31c71a

Please sign in to comment.