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

clarify img mappings #451

Closed
wants to merge 12 commits into from
Closed

clarify img mappings #451

wants to merge 12 commits into from

Conversation

scottaohara
Copy link
Member

@scottaohara scottaohara commented Dec 13, 2022

closes #439

This PR provides more detailed conditions for when an img element is mapped to the img role.

This was originally brought up to address what should happen when an img lacks or has been given an src attribute set to the empty string, as HTML defines such instances as "representing nothing". However, in trying to just add in that condition, it made me realize the mappings were lacking additional nuance to how the element is exposed re: the existence of alternative naming mechanisms besides just alt.

I have the following examples to fit these conditions:

Presentation role:

<img src> 
<img srcset> 
<img src srcset> 
<img alt>
<img src alt>
<img srcset alt>
<img src srcset alt>
<img src=foo.jpg alt>
<img src=foo.jpg srcset="..." alt>
<img src=foo.jpg alt title=foo>
<img srcset=foo.jpg alt title=foo>
<img src=foo.jpg srcset=... alt title=foo>

Image role:

<img alt=foo>
<img src=foo.jpg>
<img title=foo>
<img src alt=foo>
<img src title=foo>
<img aria-label=foo>
<img aria-labelledby=f><span id=f>foo</span>
<img src aria-label=foo>
<img src aria-labelledby=f><span id=f>foo</span>
<img src alt aria-label=foo>
<img src alt aria-labelledby=f><span id=f>foo</span>
<img src=foo.jpg alt aria-label=foo>
<img src=foo.jpg alt aria-labelledby=f><span id=f>foo</span>

Question on what to do with src=" ". I'd assume that too should be treated like src and src="". So maybe this PR also needs to call out src with a whitespace value?

Implementation

  • WPT tests: LINK
  • Implementations (link to issue or when done, link to commit):

Preview | Diff

closes #439

This PR provides more detailed conditions for when an `img` element is mapped to the `img` role. 

This was originally brought up to address what should happen when an `img` lacks or has been given an `src` attribute set to the empty string, as HTML defines such instances as "representing nothing".  However, in trying to just add in that condition, it made me realize the mappings were lacking additional nuance to how the element is exposed re: the existence of alternative naming mechanisms besides just `alt`.
index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
@scottaohara
Copy link
Member Author

Added updates to this PR to indicate that srcset should also be used in determining which role the img element maps to - particularly due to whatwg/html#9181 where src is being proposed to be optional if an srcset attribute is present on the img.

@scottaohara
Copy link
Member Author

@jnurthen @smhigley ping for review on this so i can make bugs and get this finally merged/resolved

@scottaohara
Copy link
Member Author

@cookiecrook would apprecaite your thoughts on this clarification / if I should just create a wpt test for this to help move it along?

index.html Show resolved Hide resolved
@cookiecrook
Copy link
Collaborator

@cookiecrook would appreciate your thoughts on this clarification / if I should just create a wpt test for this to help move it along?

It couldn't hurt. Well I guess it could hurt, if your expectations are wrong, and the resolving engineer doesn't question it.

I would start with a new test file of subtests that include all these variants. If the engines agree on the output, or you are certain it's right check them in. If you aren't sure in the case of one or more subtests, leave it commented or otherwise not running, and file an issue, referencing the issue in the comment.

I did something similar recently with:

Copy link

@smhigley smhigley left a comment

Choose a reason for hiding this comment

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

LGTM, pending that one empty vs. valid comment from James :)

index.html Outdated Show resolved Hide resolved
index.html Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
@rahimabdi
Copy link
Contributor

Closing, this PR has been migrated to the ARIA monorepo:

@rahimabdi rahimabdi closed this Aug 11, 2024
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.

Should an img with no src be mapped to role=img?
4 participants