Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link-in-text-block problems #3774

Closed
straker opened this issue Nov 9, 2022 · 1 comment
Closed

Link-in-text-block problems #3774

straker opened this issue Nov 9, 2022 · 1 comment
Labels
fix Bug fixes pr A pr has been created for the issue rule metadata Issues in the rule metadata code (lib/rules) rules Issue or false result from an axe-core rule

Comments

@straker
Copy link
Contributor

straker commented Nov 9, 2022

The recent changes to link-in-text-block rule has a few problems. First, the data is not converting the colors into hex, so the failureSummary is using [Object object] instead of the hex color. Also, the contrast is not being truncated so the contrast is very long decimal number.

"Fix any of the following:
The link has insufficient color contrast of 1.6620953314177012:1 with the surrounding text. (Minimum contrast is 3:1, link text: [object Object], surrounding text: [object Object])
The link has no styling (such as underline) to distinguish it from the surrounding text"

Lastly, the issue is reporting false positives for the following HTML:

<p>hello world, goodbye world
  <a href="#" style="text-decoration: none; background: #eee;">
    <style>a { color: #333 }</style>
    <img src="https://randomuser.me/api/portraits/men/54.jpg" alt=""/>
  </a>
</p>

The matches function uses textContent to determine if the link has text, but textContext grabs the text of the style element so it passes the matches.

@straker straker added fix Bug fixes rules Issue or false result from an axe-core rule rule metadata Issues in the rule metadata code (lib/rules) labels Nov 9, 2022
@straker straker added the pr A pr has been created for the issue label Nov 9, 2022
@straker straker added this to the axe-core 4.5.2 milestone Nov 9, 2022
@WilcoFiers WilcoFiers added rules Issue or false result from an axe-core rule and removed rules Issue or false result from an axe-core rule labels Nov 10, 2022
@padmavemulapati
Copy link

Validated with the latest code base,
for textContent in the link-in-text-block should grab the text of <style> and <script> elements. Should not give like link text: [object Object], surrounding text: [object Object]
Test Script:

<p style="color: black">
    paragraph of text (fail: text color has insufficient contrast against
    paragraph)
    <a
      style="text-decoration: none; color: blue"
      href="#"
      id="fail-insufficient-text-contrast"
    >
      Link text</a
    >
  </p>
  
  <p style="color: black">
    paragraph of text (fail: background color has insufficient contrast against
    paragraph)
    <a
      style="text-decoration: none; color: black; background-color: pink"
      href="#"
      id="fail-insufficient-background-contrast"
    >
      Link text</a
    >
  </p>

So now in the fix we can see the failure summary grabbing the style text content with proper color value

"Fix any of the following:
  The link has insufficient color contrast of 2.44:1 with the surrounding text. (Minimum contrast is 3:1, link text: #0000ff, surrounding text: #000000)
  The link has no styling (such as underline) to distinguish it from the surrounding text"

"Fix any of the following:
  The link background has insufficient color contrast of 1.53 (Minimum contrast is 3:1, link background color: #ffc0cb, surrounding background color: #ffffff)
  The link has no styling (such as underline) to distinguish it from the surrounding text"

image

We can see the issue reproduced in the old version:

"Fix any of the following:
  The link has insufficient color contrast of 2.444:1 with the surrounding text. (Minimum contrast is 3:1, link text: [object Object], surrounding text: [object Object])
  The link has no styling (such as underline) to distinguish it from the surrounding text"

"Fix any of the following:
  The link background has insufficient color contrast of 1.5379867185268434 (Minimum contrast is 3:1, link background color: [object Object], surrounding background color: [object Object])
  The link has no styling (such as underline) to distinguish it from the surrounding text"

image

@WilcoFiers WilcoFiers removed this from the axe-core 4.5.3 milestone Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fixes pr A pr has been created for the issue rule metadata Issues in the rule metadata code (lib/rules) rules Issue or false result from an axe-core rule
Projects
None yet
Development

No branches or pull requests

3 participants