5
5
import {
6
6
roles ,
7
7
elementRoles ,
8
- roleElements ,
9
8
} 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' ;
11
18
import getTabIndex from './getTabIndex' ;
12
19
import DOMElements from './attributes/DOM.json' ;
13
20
@@ -16,10 +23,16 @@ const nonInteractiveRoles = new Set(
16
23
) ;
17
24
18
25
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
+ ] ) : {
20
32
[ elementName : string ] : ( attributes : Array < Object > ) => boolean ,
21
33
} => {
22
34
const nonInteractiveElements = accumulator ;
35
+ // $FlowFixMe: Flow is incorrectly inferring that this is a number.
23
36
const elementSchema = JSON . parse ( elementSchemaJSON ) ;
24
37
const elementName = elementSchema . name ;
25
38
const elementAttributes = elementSchema . attributes || [ ] ;
@@ -65,7 +78,10 @@ export const nonInteractiveElementsMap = {
65
78
* an inherent role are not considered. For those, this utility returns false
66
79
* because a positive determination of interactiveness cannot be determined.
67
80
*/
68
- const isNonInteractiveElement = ( tagName , attributes ) = > {
81
+ const isNonInteractiveElement = (
82
+ tagName : string ,
83
+ attributes : Array < JSXAttribute > ,
84
+ ) : boolean => {
69
85
// Do not test higher level JSX components, as we do not know what
70
86
// low-level DOM element this maps to.
71
87
if ( Object . keys ( DOMElements ) . indexOf ( tagName ) === - 1 ) {
0 commit comments