GithubHelp home page GithubHelp logo

Comments (13)

beefancohen avatar beefancohen commented on May 18, 2024

I agree on the first one, since we can't determine the value of foo until runtime. However, not sure about the second - You can place a space in between the quotation marks (<img alt=" " />) and it should pass and still semantically represent the same thing to a screen reader. Also, I can implement case where alt="" (or any other form of undefined value) passes lint rule if role=presentation is present.

from eslint-plugin-jsx-a11y.

lencioni avatar lencioni commented on May 18, 2024

I think the role=presentation bit makes sense. According to the spec, it should probably enforce alt="" if it has a presentation role.

Authors SHOULD NOT provide meaningful alternative text (for example, use alt="" in HTML4) when the presentation role is applied to an image.

https://www.w3.org/TR/wai-aria/roles#presentation

from eslint-plugin-jsx-a11y.

beefancohen avatar beefancohen commented on May 18, 2024

Fixing first example in 0.5.3 - will upgrade minor on role=presentation enhancement. 0.5.3 should be done within the hour.

from eslint-plugin-jsx-a11y.

lencioni avatar lencioni commented on May 18, 2024

Awesome! Thanks again!

from eslint-plugin-jsx-a11y.

beefancohen avatar beefancohen commented on May 18, 2024

0.5.3 published - should fix first use case + other bugs that are closed!

from eslint-plugin-jsx-a11y.

lencioni avatar lencioni commented on May 18, 2024

I think this is still broken for cases like

function Foo() {
  return <img alt={foo.bar || ''} />;
}

and

function Foo() {
  return <img alt={bar() || ''} />;
}

and

function Foo() {
  return <img alt={foo.bar() || ''} />;
}

from eslint-plugin-jsx-a11y.

beefancohen avatar beefancohen commented on May 18, 2024

Added test cases for those and fixed in v0.5.4 - still may be other edge cases, working on resolving cases to handle each type specified in spec

from eslint-plugin-jsx-a11y.

lencioni avatar lencioni commented on May 18, 2024

Wonderful!

from eslint-plugin-jsx-a11y.

lencioni avatar lencioni commented on May 18, 2024

@evcohen do you have an ETA on the role="presentation" change? No rush--I'm just wondering if I should roll with alt=" " or wait it out.

from eslint-plugin-jsx-a11y.

beefancohen avatar beefancohen commented on May 18, 2024

@lencioni waiting for ci build to pass and then publishing v0.6.0. Error message updated and this strictly allows only the following scenario <img alt="" role="presentation" />

bad:

<img alt={``} role="presentation" /> etc. as we only want to deal with literals for this case.

from eslint-plugin-jsx-a11y.

lencioni avatar lencioni commented on May 18, 2024

I noticed that the Chrome audit rules allows alt="" without role="presentation" and role="presentation" without alt="", FYI: https://github.com/GoogleChrome/accessibility-developer-tools/wiki/Audit-Rules#ax_text_02

from eslint-plugin-jsx-a11y.

beefancohen avatar beefancohen commented on May 18, 2024

Use the attributes alt="", role="presentation" or include the image as a CSS background-image to identify it as being used purely for stylistic or decorative purposes and that it should be ignored by people using assistive technologies.
Source: http://fae20.cita.illinois.edu/rule/ARIA_STRICT/IMAGE_2/

Not sure what the real rule is in this case, but as a linter, I think it's better to be opinionated in a case like this or give users configuration options to manage the rigidity of the rule. My thinking is, the only time alt can be undefined (not just ="", but literally non-existent) is when role="presentation". In this sense, we can drop the check for alt altogether if role="presentation" is present. Thoughts?

from eslint-plugin-jsx-a11y.

lencioni avatar lencioni commented on May 18, 2024

My reading of the text you posted agrees with the Chrome text I lined to, and it also fits my intuitive understanding. I think it makes sense to enforce the existence of alt unless role="presentation", and if role="presentation" enforce either non-existent or empty alt.

from eslint-plugin-jsx-a11y.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.