@@ -3,10 +3,12 @@ import JSXElementMock from 'JSXElementMock';
3
3
import DOMElements from '../src/util/attributes/DOM.json' ;
4
4
import roles from '../src/util/attributes/role.json' ;
5
5
6
- const pureInteractiveElements = { } ;
7
- Object . keys ( DOMElements )
6
+ const pureInteractiveElements = Object . keys ( DOMElements )
8
7
. filter ( name => DOMElements [ name ] . interactive === true )
9
- . forEach ( name => pureInteractiveElements [ name ] = [ ] ) ;
8
+ . reduce ( ( interactiveElements , name ) => {
9
+ interactiveElements [ name ] = [ ] ;
10
+ return interactiveElements ;
11
+ } , { } ) ;
10
12
11
13
const interactiveElementsMap = {
12
14
...pureInteractiveElements ,
@@ -21,10 +23,12 @@ const interactiveElementsMap = {
21
23
] ,
22
24
} ;
23
25
24
- const pureNonInteractiveElementsMap = { } ;
25
- Object . keys ( DOMElements )
26
+ const pureNonInteractiveElementsMap = Object . keys ( DOMElements )
26
27
. filter ( name => ! DOMElements [ name ] . interactive )
27
- . forEach ( name => pureNonInteractiveElementsMap [ name ] = [ ] ) ;
28
+ . reduce ( ( nonInteractiveElements , name ) => {
29
+ nonInteractiveElements [ name ] = [ ] ;
30
+ return nonInteractiveElements ;
31
+ } , { } ) ;
28
32
29
33
const nonInteractiveElementsMap = {
30
34
...pureNonInteractiveElementsMap ,
@@ -42,14 +46,13 @@ const nonInteractiveRoles = Object.keys(roles).filter(
42
46
) ;
43
47
44
48
export function genInteractiveElements ( ) {
45
- const elements = [ ] ;
46
- for ( const name in interactiveElementsMap ) {
47
- const attributes = interactiveElementsMap [ name ] . map (
48
- ( { prop, value} ) => JSXAttributeMock ( prop , value )
49
- ) ;
50
- elements . push ( JSXElementMock ( name , attributes ) ) ;
51
- }
52
- return elements ;
49
+ return Object . keys ( interactiveElementsMap )
50
+ . map ( name => {
51
+ const attributes = interactiveElementsMap [ name ] . map (
52
+ ( { prop, value} ) => JSXAttributeMock ( prop , value )
53
+ ) ;
54
+ return JSXElementMock ( name , attributes ) ;
55
+ } ) ;
53
56
}
54
57
55
58
export function genInteractiveRoleElements ( ) {
@@ -61,14 +64,13 @@ export function genInteractiveRoleElements () {
61
64
}
62
65
63
66
export function genNonInteractiveElements ( ) {
64
- const elements = [ ] ;
65
- for ( const name in nonInteractiveElementsMap ) {
66
- const attributes = nonInteractiveElementsMap [ name ] . map (
67
- ( { prop, value} ) => JSXAttributeMock ( prop , value )
68
- ) ;
69
- elements . push ( JSXElementMock ( name , attributes ) ) ;
70
- }
71
- return elements ;
67
+ return Object . keys ( nonInteractiveElementsMap )
68
+ . map ( name => {
69
+ const attributes = nonInteractiveElementsMap [ name ] . map (
70
+ ( { prop, value} ) => JSXAttributeMock ( prop , value )
71
+ ) ;
72
+ return JSXElementMock ( name , attributes ) ;
73
+ } ) ;
72
74
}
73
75
74
76
export function genNonInteractiveRoleElements ( ) {
0 commit comments