Skip to content

Commit

Permalink
Ensure empty 2F text is ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Dec 31, 2022
1 parent cd69d4a commit e562b75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions sources/__tests__/accessible-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ test.each([
`<img data-test alt="" aria-label="a logo" role="presentation" /> />`,
"a logo",
],
[` <input type="radio" data-test title="crazy"/>`, "crazy"],
])(`misc #%#`, (markup, expectedAccessibleName) => {
expect(markup).toRenderIntoDocumentAccessibleName(expectedAccessibleName);
});
Expand Down
7 changes: 5 additions & 2 deletions sources/accessible-name-and-description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,14 @@ export function computeTextAlternative(
isNativeHostLanguageTextAlternativeElement(current) ||
isDescendantOfNativeHostLanguageTextAlternativeElement(current)
) {
consultedNodes.add(current);
return computeMiscTextAlternative(current, {
const accumulatedText2F = computeMiscTextAlternative(current, {
isEmbeddedInLabel: context.isEmbeddedInLabel,
isReferenced: false,
});
if (accumulatedText2F !== "") {
consultedNodes.add(current);
return accumulatedText2F;
}
}

if (current.nodeType === current.TEXT_NODE) {
Expand Down

0 comments on commit e562b75

Please sign in to comment.