forked from jsx-eslint/eslint-plugin-jsx-a11y
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisInteractiveElement.js
More file actions
29 lines (24 loc) · 782 Bytes
/
Copy pathisInteractiveElement.js
File metadata and controls
29 lines (24 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';
import hasAttribute from './hasAttribute';
const interactiveMap = {
a: attributes => {
const hasHref = hasAttribute(attributes, 'href');
const hasTabIndex = hasAttribute(attributes, 'tabIndex');
return (Boolean(hasHref) || !hasHref && Boolean(hasTabIndex));
},
button: () => true,
input: attributes => {
const hasTypeAttr = hasAttribute(attributes, 'type');
return hasTypeAttr ? hasTypeAttr.value.value.toUpperCase() !== 'HIDDEN' : true;
},
option: () => true,
select: () => true,
textarea: () => true
};
const isInteractiveElement = (tagName, attributes) => {
if (interactiveMap.hasOwnProperty(tagName) === false) {
return false;
}
return interactiveMap[tagName](attributes);
};
export default isInteractiveElement;