-
Notifications
You must be signed in to change notification settings - Fork 788
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
Custom Elements using ElementInternals
to set role
are flagged when aria-label
is provided
#4259
Comments
Thanks for the issue. We'll need to do some extensive research to see how much assistive technologies support different element internal properties. If they support it, adding support to axe-core will take a lot of time as we have exclusively been looking at just the available element attributes to get ARIA information. Supporting this will require an extensive change in how we access ARIA information throughout the entire codebase. |
* docs(button): fix demo * fix(button)!: remove shadow <button> Closes #2706 * fix(chip): use the new pf-button * test(button): form submit * fix(button): click event on space/enter * test(chip): refactor tests * test: update tests * test(back-to-top): fix a11y assertion * test(dropdown): skip aria attrs assertion see dequelabs/axe-core#4259
Would love to see this added the library!! |
Ooof, the move to How could the community support bringing this feature to the project? |
@Westbrook The biggest support we could get from the community is to determine how well |
Thanks for the feedback @straker! 🙇🏼 Digging into that issue a little and then will see what sort of test suite I might be able to work together to get some of this information. Is there a test context that the team uses for ensuring other accessibility tree relationships that would be good to work from, in hopes of reducing friction further down the road? |
Related, @straker have you ever worked with https://playwright.dev/docs/api/class-accessibility#accessibility-snapshot? While it's deprecated (pouring on our for it), interestingly enough for your tools, I've had pretty nice success with it. Would a test suite that tests for an equivelent accessibility tree between a native DOM implementation and a custom element implementation of similar being a useful first pass? Playwright runs across WebKit, Firefox and Chromium and while it removes the use of multiple screen readers in the test phase the assumption that the trees being of similar shape should give enough signal, even before moving to a fully manual review of the various screen readers, right? |
The above would allow us to write demos like this and then test their equality like this. The logs therein come out like:
|
Thanks for that information. Unfortunately what the browser reports / logs at the accessibility tree layer is only a partial understanding. In the end what matters is what screen readers do. So it will require using screen readers to understand what they do with the information they're given. To answer the prior question, I talked with the team and we don't have a single page where we have test cases. The closet we would have is all our individual integration tests which shows how we expect different combinations of things to work. However they feel that before we ask for community help in testing that we'll need to come up with the testing matrix first to make sure we understand what needs to be covered before testing. |
So the reason I think this approach works is that if this DOM:
And this DOM:
were to both create the same tree, it no longer matters what the screen reader does with with the accessibility tree. Either the screen readers already leverage DOM incorrectly or they will do the same things as the native elements. I understand that it isn't the same as manual testing, but I do see it as having a high quality signal as to the direction this work should go in. However, if that's still not a valid enough step, then we can work towards a different solution. Having a testing matrix in either case will be very helpful. Would you and the team be able to prioritize preparing something like that? I'm the chairperson at https://github.com/w3c/webcomponents-cg and I'd love to get a concrete path forward that we could spread out across a number of accessibility interested members of the group (which should be all of them, 😉). |
As far as I can tell there is no reliable way to get to the Even if There are a lot of opportunities for things to go wrong here. And if axe can't detect an attached |
While the complexity of possibly expanding browser APIs moves forward... Thinking about this more, I wonder if there is a configuration point that I've not yet found wherein a consuming developer could expand the values exported by https://github.com/dequelabs/axe-core/blob/develop/lib/commons/standards/implicit-html-roles.js#L72? In this way, while a developer would be taking on some level of responsibility for the truth of the role applied to an element, the wide ranging benefits of |
@WilcoFiers can you patch attachInternals? https://codepen.io/bennyp/pen/RwzaWwd const aXeMap = new WeakMap;
const orig = HTMLElement.prototype.attachInternals;
HTMLElement.prototype.attachInternals = function () {
const internals = orig.call(this);
aXeMap.set(this, internals);
return internals;
}; |
No, not reliably. The most important reason is that Secondarily, axe-core is often injected as part of a different javascript context from the rest of the page (eg, as part of a webextension content script) - there are workarounds for that (eg, injecting a script tag into the DOM to implement the patch), but they involve weakening the affected cases' security models. |
Product
axe-core
Product Version
4.8.2
Latest Version
Issue Description
We are currently migrating our Web Component library to use the
ElementInternals
API to set default ARIA attributes, such asrole
, on all of our semantic host elements instead of sprouting theserole
attributes when the element is connected. This allows for setting default semantics, while still allowing for consumers to override these semantics if necessary. Upon doing so, axe is flagging some of these custom elements as critical issues that appear to be false positives.It's worth noting that axe will not flag these elements if any non-empty text nodes appear in the shadow DOM of the element, or if the
role
attribute is set directly on the element.Expectation
Custom Elements that use
ElementInternals
to set their defaultrole
should not be flagged by axe-core.Actual
The extension produced the following critical error:
How to Reproduce
The following codepen is a reproduction in the simplest form that shows a custom element with a default
role
ofprogressbar
set viaElementInternals
, along with anaria-label
set in the light DOM on the host:https://codepen.io/drifty17/full/WNPgvoM
Open the axe extension in DevTools and scan the page to see the error:
Upon viewing the accessibility tree you can also see that the semantics appear to be set properly (tested with VoiceOver as well and it interpreted it correctly):
Additional context
I added an additional (working) example of a separate custom element for comparison that is identical except that it will sprout the
role
attribute when it connects to the DOM. When therole
attribute is present on the element, axe does not flag the element, but when the samerole
is set viaElementInternals
instead it does get flagged.The text was updated successfully, but these errors were encountered: