Skip to content

Commit 84d0078

Browse files
jessebeachbeefancohen
authored andcommitted
Pull the isLink check in isInterativeElement util into its own function
1 parent d8ba4b0 commit 84d0078

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/util/isInteractiveElement.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@ const pureInteractiveElements = Object.keys(DOMElements)
1212
return interactiveElements;
1313
}, {});
1414

15+
const isLink = function isLink(attributes) {
16+
const href = getPropValue(getProp(attributes, 'href'));
17+
const tabIndex = getTabIndex(getProp(attributes, 'tabIndex'));
18+
return href !== undefined || tabIndex !== undefined;
19+
};
20+
1521
export const interactiveElementsMap = {
1622
...pureInteractiveElements,
17-
a: (attributes) => {
18-
const href = getPropValue(getProp(attributes, 'href'));
19-
const tabIndex = getTabIndex(getProp(attributes, 'tabIndex'));
20-
return href !== undefined || tabIndex !== undefined;
21-
},
22-
// This is same as `a` interactivity function
23-
area: (attributes) => {
24-
const href = getPropValue(getProp(attributes, 'href'));
25-
const tabIndex = getTabIndex(getProp(attributes, 'tabIndex'));
26-
return href !== undefined || tabIndex !== undefined;
27-
},
23+
a: isLink,
24+
area: isLink,
2825
input: (attributes) => {
2926
const typeAttr = getLiteralPropValue(getProp(attributes, 'type'));
3027
return typeAttr ? typeAttr.toUpperCase() !== 'HIDDEN' : true;

0 commit comments

Comments
 (0)