Skip to content

fix(label-content-name-mismatch): match visible text with aria-label and exclude invisible text - #5096

Merged
WilcoFiers merged 4 commits into
dequelabs:developfrom
mehm8128:label-content-name-mismatch-invisible-text
May 15, 2026
Merged

fix(label-content-name-mismatch): match visible text with aria-label and exclude invisible text#5096
WilcoFiers merged 4 commits into
dequelabs:developfrom
mehm8128:label-content-name-mismatch-invisible-text

Conversation

@mehm8128

@mehm8128 mehm8128 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Using visibleVirtual instead of subtreeText, I resolved issue.
Because if I simple replace it and use isIconLigature existing two tests failed ('returns true when visible text excluding ligature icon is part of accessible name' and 'returns true when text contains <br/>'), I changed visible-virtual.js, but I'm not sure this is proper changes (this is the first PR for me to axe-core).

Closes: #5063

@mehm8128
mehm8128 requested a review from a team as a code owner May 5, 2026 13:29
Copilot AI review requested due to automatic review settings May 5, 2026 13:29
@CLAassistant

CLAassistant commented May 5, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

}
if (
ignoreIconLigature &&
isIconLigature(child, pixelThreshold, occurrenceThreshold)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should judge isIconLigature here because it needs child node as its first param

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates label-content-name-mismatch so it compares accessible names against visually rendered text instead of subtree accessible text, addressing false positives like img[alt] and SVG <title> content being treated as visible label text.

Changes:

  • Swapped the check’s visible-text computation from subtreeText() to a visibleVirtual()-based traversal.
  • Added integration and unit coverage for img[alt], SVG title, <br>, and icon-ligature scenarios.
  • Extended visibleVirtual() with options for ignoring icon ligatures during visible-text extraction.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/integration/rules/label-content-name-mismatch/label-content-name-mismatch.json Updates expected pass/fail fixtures for new label/content cases.
test/integration/rules/label-content-name-mismatch/label-content-name-mismatch.html Adds HTML fixtures covering img[alt] and SVG title visible-label scenarios.
test/commons/text/visible-virtual.js Adds tests for the new visibleVirtual ligature-filtering options.
test/checks/label/label-content-name-mismatch.js Adds unit coverage for the img[alt] false-positive regression.
lib/commons/text/visible-virtual.js Adds optional icon-ligature filtering to visible-text extraction.
lib/checks/label/label-content-name-mismatch-evaluate.js Reworks the check to derive visible text from rendered content instead of subtree accessible text.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/checks/label/label-content-name-mismatch-evaluate.js Outdated
Comment thread lib/checks/label/label-content-name-mismatch-evaluate.js Outdated
@mehm8128
mehm8128 force-pushed the label-content-name-mismatch-invisible-text branch 2 times, most recently from 964edbb to 3370354 Compare May 5, 2026 14:02
Comment on lines +54 to +56
if (nodeName === 'br') {
return ' ';
}

@mehm8128 mehm8128 May 5, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should replace <br> with ' ' to pass 'returns true when text contains <br/>' test

@WilcoFiers WilcoFiers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I think this is missing one test.

var actual = check.evaluate(vNode.actualNode, options, vNode);
assert.isTrue(actual);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a ligature font unit test here as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added more test cases!

@WilcoFiers WilcoFiers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have made that a change request.

@mehm8128
mehm8128 requested a review from WilcoFiers May 6, 2026 13:33
WilcoFiers
WilcoFiers previously approved these changes May 12, 2026
@WilcoFiers

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

mehm8128 added 2 commits May 13, 2026 23:53
…ntents instead of `subtreeText`

Use `visibleVirtual` instead of `subtreeText` in order to match visible text with aria-label and exclude invisible text.

closes issue dequelabs#5063
… font

Add more test cases using ligature font and normal invalid case.

closes issue dequelabs#5063
@mehm8128
mehm8128 force-pushed the label-content-name-mismatch-invisible-text branch from aed738e to 21c2d6e Compare May 13, 2026 15:07
@mehm8128

Copy link
Copy Markdown
Contributor Author

Copilot didn't seem to be working, so I resolved the conflict manually

@mehm8128
mehm8128 requested a review from WilcoFiers May 13, 2026 15:14
@WilcoFiers

Copy link
Copy Markdown
Contributor

@mehm8128 would you mind running Prettier? the fmt_check is failing because of it.

@mehm8128

Copy link
Copy Markdown
Contributor Author

@WilcoFiers done

@WilcoFiers WilcoFiers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you @mehm8128!

For the books, I reviewed this PR for security.

@WilcoFiers
WilcoFiers merged commit 3a012a1 into dequelabs:develop May 15, 2026
22 of 23 checks passed
WilcoFiers added a commit that referenced this pull request Jun 1, 2026
##
[4.12.0](v4.11.4...v4.12.0)
(2026-06-01)

### Features

- add gather-internals.js external script
([#5099](#5099))
([c61d58b](c61d58b)),
closes [#5080](#5080)
- **aria-allowed/prohibited-attr, aria-required-parent/children:**
partially support element internals role
([#5080](#5080))
([417b48a](417b48a)),
closes [#5039](#5039)
[#4259](#4259)
- **axe.externalAPIs:** add public api for setting elementInternal data
([#5105](#5105))
([63bab8f](63bab8f))
- **core:** expose normalizeRunOptions
([#4998](#4998))
([b8e6a59](b8e6a59))
- expose axe.resetLocale() to restore the default locale
([#5108](#5108))
([c2b5292](c2b5292)),
closes [#5107](#5107)
- **getRules:** include rule enabled state in returned objects
([#5118](#5118))
([75bf772](75bf772)),
closes [#5116](#5116)
- **list,listitem:** support element internals role
([#5119](#5119))
([7d9d696](7d9d696))
- **new-rule:** check that aria-tab have an accessible name
([#5001](#5001))
([0d4e4e7](0d4e4e7)),
closes [#4842](#4842)
- **rules:** deprecate landmark-complementary-is-top-level rules
([#4992](#4992))
([9e09139](9e09139)),
closes [#4950](#4950)
- **utils:** add `getElementInternals` function
([#5077](#5077))
([1c15f82](1c15f82))

### Bug Fixes

- **aria-allowed-attr:** restrict br and wbr elements to aria-hidden
only ([#4974](#4974))
([c6245e7](c6245e7))
- **aria-conditional-attr:** add support for radio
([#5100](#5100))
([8223c98](8223c98))
- **aria-valid-attr-value:** handle multiple aria-errormessage IDs
([#4973](#4973))
([0489e30](0489e30))
- **aria:** prevent getOwnedVirtual from returning duplicate nodes
([#4987](#4987))
([48ca955](48ca955)),
closes [#4840](#4840)
- **commons/text:** exclude natively hidden elements from
aria-labelledby accessible name
([#5076](#5076))
([ea7202c](ea7202c)),
closes [#4704](#4704)
- **DqElement:** avoid calling constructors with cloneNode
([#5013](#5013))
([0281fa1](0281fa1))
- **existing-rule:** aria-busy now shows an error message for a use with
unallowed children
([#5017](#5017))
([2067b87](2067b87))
- **helpUrl:** ensure axe.configure always updates the help URLs
([#5114](#5114))
([c4f60ff](c4f60ff))
- **label-content-name-mismatch:** match visible text with aria-label
and exclude invisible text
([#5096](#5096))
([3a012a1](3a012a1))
- **locale:** ensure all subtags are correctly set
([#5112](#5112))
([13005ed](13005ed))
- **scrollable-region-focusable:** clarify the issue is in safari
([#4995](#4995))
([4ec5211](4ec5211)),
closes
[WebKit#190870](https://github.com/dequelabs/WebKit/issues/190870)
[WebKit#277290](https://github.com/dequelabs/WebKit/issues/277290)
- **scrollable-region-focusable:** do not fail scroll areas when all
content is visible without scrolling
([#4993](#4993))
([838707a](838707a))
- **target-size:** determine offset using clientRects if target is
display:inline
([#5012](#5012))
([a4b8091](a4b8091))
- **target-size:** ignore position: fixed elements that are offscreen
when page is scrolled
([#5066](#5066))
([1229a6e](1229a6e)),
closes [#5065](#5065)
- **target-size:** ignore widgets that are inline with other inline
elements ([#5000](#5000))
([a8dd81b](a8dd81b))
- **utils/getAncestry:** escape node name
([#5079](#5079))
([d1fabaa](d1fabaa)),
closes [#5078](#5078)
- **utils:** Add null check to parseCrossOriginStylesheet, closes
[#5074](#5074)
([#5075](#5075))
([f12ef32](f12ef32))
- **utils:** update isShadowRoot to use spec-compliant custom element
regex ([#5059](#5059))
([edc6ce2](edc6ce2)),
closes [#5030](#5030)

This PR was opened by a robot 🤖 🎉
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

img[alt] should not be treated as text in label-content-name-mismatch

4 participants