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

Should SVG with no accessible children have role=img? #12

Open
AmeliaBR opened this issue Feb 3, 2020 · 5 comments
Open

Should SVG with no accessible children have role=img? #12

AmeliaBR opened this issue Feb 3, 2020 · 5 comments

Comments

@AmeliaBR
Copy link
Contributor

AmeliaBR commented Feb 3, 2020

See discussion: w3c/html-aam#43
(This came up on Twitter and I couldn't find the issue because it was on HTML-AAM instead of SVG-AAM.)

Summary of issue:
Currently, the SVG element is mapped to the graphics-document ARIA role.

Most uses of inline SVG on the web are for simple icons, where the "document" nature of the SVG tree isn't relevant — there are no interactive or named child nodes. It may be better for end users if these simple SVGs are just treated as regular images.

Next steps:
I'd like some feedback from implementers if they see any problem with having an element's role depend on it's child tree. If it seems feasible to include that check, then I agree that using the img role for this case, and reserving the graphics-document role for cases where there is accessible child content.

PS, probably best to keep all the discussion in the same place: on the HTML-AAM issue for now, until a decision is made.

@LJWatson
Copy link

LJWatson commented Feb 4, 2020 via email

@cookiecrook
Copy link

Also w3c/html-aam#290

@joanmarie
Copy link
Contributor

I'm working on Chromium's SVG-AAM implementation. I think we should make this mapping change.

pull bot pushed a commit to Yannic/chromium that referenced this issue Oct 13, 2021
Currently an SVG root element is treated as a document rather than an
image. Given that most SVGs on the web are for icons rather than complex
documents, this exposure might not make sense. There is an open issue in
the SVG-AAM spec's github suggesting that if an SVG has no accessible
children, it should be exposed as an image rather than as a document.
See w3c/svg-aam#12

AX-Relnotes: Expose SVGs with no accessible children as an image rather
than a document.

Bug: 231654
Change-Id: I1b05d713813ecc9546cd26b602b8f6526b41e861
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3195891
Reviewed-by: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Nektarios Paisios <nektar@chromium.org>
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#930670}
@joanmarie
Copy link
Contributor

joanmarie commented Oct 13, 2021

As the (unexpected-to-me) notification above indicates: The implementation in Chromium to expose SVG with no accessible children as role=img is done.

@jcsteh
Copy link

jcsteh commented Nov 15, 2021

As I understand it from my own testing, Chromium (at least on Windows) currently exposes all svgs as role image.

I see problems with this if the svg mutates to contain accessible children (and there's no reason that can't happen). Consider this:

data:text/html,<svg id="svg"><title>title</title></svg><script>setTimeout(() => svg.innerHTML += '<rect aria-label="rect"></rect>', 1000);</script>

The svg initially contains no accessible children, but after a second, it mutates to contain an accessible child. If we have different role mappings for svg here, the role has to change. This is a challenge for some platforms at least, particularly with roles as different as image and document.

To deal with that, should the browser recreate the whole subtree? This would require the browser to check the parent every time an accessible is added/removed from an svg subtree to see whether it needs to be recreated. There's probably no perf issue there, but it will definitely require special case code with regard to tree management, so we need to be sure this is really what we want.

mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this issue Oct 14, 2022
Currently an SVG root element is treated as a document rather than an
image. Given that most SVGs on the web are for icons rather than complex
documents, this exposure might not make sense. There is an open issue in
the SVG-AAM spec's github suggesting that if an SVG has no accessible
children, it should be exposed as an image rather than as a document.
See w3c/svg-aam#12

AX-Relnotes: Expose SVGs with no accessible children as an image rather
than a document.

Bug: 231654
Change-Id: I1b05d713813ecc9546cd26b602b8f6526b41e861
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3195891
Reviewed-by: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Nektarios Paisios <nektar@chromium.org>
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#930670}
NOKEYCHECK=True
GitOrigin-RevId: 2b46499fc2ba3e80f2b1f1e3f7fef64fa6be3c03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants