Skip to content

Commit 5323d81

Browse files
committed
refactor: self code review
1 parent b6f0e67 commit 5323d81

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/helpers/accessibility.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export function isAccessibilityElement(element: ReactTestInstance | null): boole
103103
return false;
104104
}
105105

106-
if (isHostImage(element) && element.props.alt) {
106+
// https://github.com/facebook/react-native/blob/8dabed60f456e76a9e53273b601446f34de41fb5/packages/react-native/Libraries/Image/Image.ios.js#L172
107+
if (isHostImage(element) && element.props.alt !== undefined) {
107108
return true;
108109
}
109110

@@ -162,11 +163,17 @@ export function computeAriaModal(element: ReactTestInstance): boolean | undefine
162163
}
163164

164165
export function computeAriaLabel(element: ReactTestInstance): string | undefined {
166+
const explicitLabel = element.props['aria-label'] ?? element.props.accessibilityLabel;
167+
if (explicitLabel) {
168+
return explicitLabel;
169+
}
170+
171+
//https://github.com/facebook/react-native/blob/8dabed60f456e76a9e53273b601446f34de41fb5/packages/react-native/Libraries/Image/Image.ios.js#L173
165172
if (isHostImage(element) && element.props.alt) {
166173
return element.props.alt;
167174
}
168175

169-
return element.props['aria-label'] ?? element.props.accessibilityLabel;
176+
return undefined;
170177
}
171178

172179
export function computeAriaLabelledBy(element: ReactTestInstance): string | undefined {

0 commit comments

Comments
 (0)