Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Issue #10 #13

Merged
merged 1 commit into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"env": {
"browser": true,
"node": true,
"es6": true
"es6": true,
"mocha": true
},
"parserOptions": {
"ecmaVersion": 2017,
Expand All @@ -17,6 +18,7 @@
],
"plugins": [
"babel",
"mocha",
"react"
],
"rules": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"eslint-plugin-babel": "^3.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-mocha": "^4.9.0",
"eslint-plugin-react": "^6.10.3",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.1.7",
Expand Down
9 changes: 6 additions & 3 deletions src/rules/no-unsupported-elements-use-aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default [{
msg: 'This element does not support ARIA roles, states and properties.',
AX: 'AX_ARIA_12',
test(tagName, props) {
const reserved = DOM[tagName].reserved || false;
const reserved = (Object.prototype.hasOwnProperty.call(DOM, tagName) && DOM[tagName].reserved) || false;
const prop = hasProp(props, Object.keys(aria).concat('role'));

return !reserved || !prop;
Expand All @@ -30,9 +30,12 @@ export const fail = [{
}];

export const pass = [{
when: 'the reserver element is not given an illegal prop',
when: 'the reserved element is not given an illegal prop',
render: React => <meta charSet="UTF-8" />
}, {
when: 'an illegal props is given to a non-reserved elemeent',
when: 'an illegal prop is given to a non-reserved element',
render: React => <div aria-hidden />
}, {
when: 'an illegal prop is given to an unknown element',
render: React => <g aria-hidden />
}];
9 changes: 8 additions & 1 deletion src/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,14 @@ export default class Suite {
}

// perform the test
const pass = await test(tagName, props, children, ctx);
let pass;
// try/catch so that exceptions are not silently swallowed by await
try {
pass = await test(tagName, props, children, ctx);
} catch (error) {
console.log(error);
pass = false;
}

if (!pass) {
done({
Expand Down