From d31c71ab50721377a8b5e239213139d0255f4cf5 Mon Sep 17 00:00:00 2001 From: maran Date: Wed, 16 May 2018 12:14:37 +0800 Subject: [PATCH] fix error --- lib/rules/aria-props.js | 26 ++++++++++++++------------ tests/lib/rules/aria-role.js | 5 ++++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/rules/aria-props.js b/lib/rules/aria-props.js index 235ad6e..627a0fb 100644 --- a/lib/rules/aria-props.js +++ b/lib/rules/aria-props.js @@ -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)) } diff --git a/tests/lib/rules/aria-role.js b/tests/lib/rules/aria-role.js index 8c803d7..6f19c60 100644 --- a/tests/lib/rules/aria-role.js +++ b/tests/lib/rules/aria-role.js @@ -33,7 +33,10 @@ tester.run('aria-role', rule, { }, { filename: 'test.vue', - code: '', + code: '', + options: [{ + ignoreNonDOM: true + }] }, { code: `