Skip to content

Commit 11f1bfa

Browse files
committed
Typing updates to util/isNonInteractiveElement
1 parent 2143514 commit 11f1bfa

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/util/isNonInteractiveElement.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55
import {
66
roles,
77
elementRoles,
8-
roleElements,
98
} from 'aria-query';
10-
import { getProp, getPropValue, getLiteralPropValue } from 'jsx-ast-utils';
9+
import type {
10+
JSXAttribute,
11+
} from 'ast-types-flow';
12+
import {
13+
getProp,
14+
getPropValue,
15+
getLiteralPropValue,
16+
propName,
17+
} from 'jsx-ast-utils';
1118
import getTabIndex from './getTabIndex';
1219
import DOMElements from './attributes/DOM.json';
1320

@@ -16,10 +23,16 @@ const nonInteractiveRoles = new Set(
1623
);
1724

1825
const pureNonInteractiveElements = [...elementRoles.entries()]
19-
.reduce((accumulator, [elementSchemaJSON, roleSet]): {
26+
.reduce((accumulator, [
27+
// $FlowFixMe: Flow is incorrectly inferring that this is a number.
28+
elementSchemaJSON,
29+
// $FlowFixMe: Flow is incorrectly inferring that this is a number.
30+
roleSet,
31+
]): {
2032
[elementName: string]: (attributes: Array<Object>) => boolean,
2133
} => {
2234
const nonInteractiveElements = accumulator;
35+
// $FlowFixMe: Flow is incorrectly inferring that this is a number.
2336
const elementSchema = JSON.parse(elementSchemaJSON);
2437
const elementName = elementSchema.name;
2538
const elementAttributes = elementSchema.attributes || [];
@@ -65,7 +78,10 @@ export const nonInteractiveElementsMap = {
6578
* an inherent role are not considered. For those, this utility returns false
6679
* because a positive determination of interactiveness cannot be determined.
6780
*/
68-
const isNonInteractiveElement = (tagName, attributes) => {
81+
const isNonInteractiveElement = (
82+
tagName: string,
83+
attributes: Array<JSXAttribute>,
84+
): boolean => {
6985
// Do not test higher level JSX components, as we do not know what
7086
// low-level DOM element this maps to.
7187
if (Object.keys(DOMElements).indexOf(tagName) === -1) {

0 commit comments

Comments
 (0)