Skip to content

clarify img mappings#451

Closed
scottaohara wants to merge 12 commits into
gh-pagesfrom
issue-439
Closed

clarify img mappings#451
scottaohara wants to merge 12 commits into
gh-pagesfrom
issue-439

Conversation

@scottaohara
Copy link
Copy Markdown
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`.
Comment thread index.html Outdated
Comment thread index.html Outdated
Comment thread index.html Outdated
@scottaohara
Copy link
Copy Markdown
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
Copy Markdown
Member Author

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

@scottaohara
Copy link
Copy Markdown
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?

Comment thread index.html
@cookiecrook
Copy link
Copy Markdown
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
Copy Markdown

@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 :)

Comment thread index.html Outdated
Comment thread index.html
Comment thread index.html Outdated
@rahimabdi
Copy link
Copy Markdown
Contributor

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

@rahimabdi rahimabdi closed this Aug 11, 2024
@scottaohara scottaohara deleted the issue-439 branch May 12, 2025 19:52
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