You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is to address what I believe to be a false positive result (i.e. failed audit when in fact the page would otherwise pass) when certain kinds of form-associated custom elements are in use. In particular, the case I'd like to address is a type of FACE which wraps a native input in shadow dom and reimplements it's semantics on the host element.
Please consider the following page:
<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport" content="width=device-width"><title>Interactive elements aria hidden in a FACE shadow root</title><scripttype="module">classFormAssociatedCheckboxElementextendsHTMLElement{staticis='face-checkbox';staticformAssociated=true;staticobservedAttributes=['checked'];static{customElements.define(this.is,this);}
#internals =this.attachInternals();get #input(){returnthis.shadowRoot.getElementById('input');}getchecked(){returnthis.hasAttribute('checked');}setchecked(v){this.toggleAttribute('checked',!!v);}attributeChangedCallback(name,old,val){this.#input.checked=val!==null;this.#internals.ariaChecked=String(!!this.checked);}connectedCallback(){this.#internals.role='checkbox';this.#input.addEventListener('click',(event)=>{this.checked=this.#input.checked;});}}</script></head><body><labelfor="checkbox">Checked?</label><face-checkboxid="checkbox" checked><templateshadowrootmode="open"
shadowrootdelegatesfocus="true"><inputaria-hidden="true" id="input" type="checkbox"></template></face-checkbox></body></html>
This page contains a label and a form associated custom element with attached element internals. The shadow root of the element delegates focus to a checkbox element in the shadow root. Because the face element is form associated, and because it manages it's own semantics via it's attached ElementInternals object, it should be acceptable for the shadow checkbox to be hidden from AT. In fact, firefox' accessibility inspector shows that because of the work of the element author, the correct states are communicated to AT:
Although ORCA/FireFox apparently handle this page as expected, axe DevTools insists that this is in fact an error:
I propose that in cases like these, this requirement be relaxed. axe core could take one of a variety of approaches to validating the custom element code / element internals state:
when encountering a form-associated custom element with a shadowroot and an aria-hidden interactive element inside, axe-core could ignore the shadow element and advise the user to run manual testing to verify that it works with AT
Thanks for the report, and especially for providing a great self-contained repro! We know generally that we need to think about ElementInternals support more broadly in the near future.
This issue is to address what I believe to be a false positive result
I don't think this specific case is a false positive; this pattern really does cause a variety of accessibility problems for ATs today. With the repro page you provided above:
Open the page in Chromium on MacOS, enable VoiceOver, tab to the control, and observe that VoiceOver doesn't announce the control's label as part of the control's name
Open the page in Chromium on Windows, enable NVDA, tab to the control, and observe that NVDA double-announces the control type and state
Open the page in Firefox on Windows, enable NVDA, tab to the control, and observe that although it is announced correctly, it breaks keyboard operability with space/enter keys
Open the page on Windows (either Chromium or Firefox), enable Windows Voice Access, speak a command to click on the control, and observe that it won't recognize the command
Because the face element is form associated, and because it manages it's own semantics via it's attached ElementInternals object, it should be acceptable for the shadow checkbox to be hidden from AT. In fact, firefox' accessibility inspector shows that because of the work of the element author, the correct states are communicated to AT.
It isn't enough for some browsers to produce reasonable looking accessibility trees; WCAG (and by extension axe-core) require that new techniques meet WCAG's accessibility supported criteria before axe-core can treat the technique as acceptable.
axe core could override the attachElements method on HTMLElement
Unfortunately, axe-core can't really use this approach because axe-core needs to remain compatible with users injecting it onto a page after the page is loaded. I posted some more details in a comment on the original issue.
Product
axe-core
Feature Description
This issue is to address what I believe to be a false positive result (i.e. failed audit when in fact the page would otherwise pass) when certain kinds of form-associated custom elements are in use. In particular, the case I'd like to address is a type of FACE which wraps a native input in shadow dom and reimplements it's semantics on the host element.
Please consider the following page:
This page contains a label and a form associated custom element with attached element internals. The shadow root of the element delegates focus to a checkbox element in the shadow root. Because the face element is form associated, and because it manages it's own semantics via it's attached
ElementInternals
object, it should be acceptable for the shadow checkbox to be hidden from AT. In fact, firefox' accessibility inspector shows that because of the work of the element author, the correct states are communicated to AT:Although ORCA/FireFox apparently handle this page as expected, axe DevTools insists that this is in fact an error:
I propose that in cases like these, this requirement be relaxed. axe core could take one of a variety of approaches to validating the custom element code / element internals state:
attachElements
method on HTMLElement, to capture the internals object for each element in a weakmap, and use that captured reference to assert on the internal consistency of those ElementInternals objects (see Custom Elements usingElementInternals
to setrole
are flagged whenaria-label
is provided #4259 (comment)):The text was updated successfully, but these errors were encountered: