Skip to content

Commit 3173a1d

Browse files
author
Erin Doyle
committed
Fixed #10 where if a tagName is being checked for reserved in the DOM object but does not exist in the DOM object an exception was being thrown
1 parent 3cb951f commit 3173a1d

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"env": {
33
"browser": true,
44
"node": true,
5-
"es6": true
5+
"es6": true,
6+
"mocha": true
67
},
78
"parserOptions": {
89
"ecmaVersion": 2017,
@@ -17,6 +18,7 @@
1718
],
1819
"plugins": [
1920
"babel",
21+
"mocha",
2022
"react"
2123
],
2224
"rules": {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"eslint-plugin-babel": "^3.1.0",
5050
"eslint-plugin-import": "^2.2.0",
5151
"eslint-plugin-jsx-a11y": "^3.0.2",
52+
"eslint-plugin-mocha": "^4.9.0",
5253
"eslint-plugin-react": "^6.10.3",
5354
"karma": "^0.13.22",
5455
"karma-chrome-launcher": "^0.1.7",

src/rules/no-unsupported-elements-use-aria.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default [{
99
msg: 'This element does not support ARIA roles, states and properties.',
1010
AX: 'AX_ARIA_12',
1111
test(tagName, props) {
12-
const reserved = DOM[tagName].reserved || false;
12+
const reserved = (Object.prototype.hasOwnProperty.call(DOM, tagName) && DOM[tagName].reserved) || false;
1313
const prop = hasProp(props, Object.keys(aria).concat('role'));
1414

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

3232
export const pass = [{
33-
when: 'the reserver element is not given an illegal prop',
33+
when: 'the reserved element is not given an illegal prop',
3434
render: React => <meta charSet="UTF-8" />
3535
}, {
36-
when: 'an illegal props is given to a non-reserved elemeent',
36+
when: 'an illegal prop is given to a non-reserved element',
3737
render: React => <div aria-hidden />
38+
}, {
39+
when: 'an illegal prop is given to an unknown element',
40+
render: React => <g aria-hidden />
3841
}];

src/test.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,14 @@ export default class Suite {
120120
}
121121

122122
// perform the test
123-
const pass = await test(tagName, props, children, ctx);
123+
let pass;
124+
// try/catch so that exceptions are not silently swallowed by await
125+
try {
126+
pass = await test(tagName, props, children, ctx);
127+
} catch (error) {
128+
console.log(error);
129+
pass = false;
130+
}
124131

125132
if (!pass) {
126133
done({

0 commit comments

Comments
 (0)