[wp-trac] [WordPress Trac] #47975: Prevent aria-describedby broken reference in `comment_form()`
WordPress Trac
noreply at wordpress.org
Wed Sep 4 21:12:42 UTC 2019
#47975: Prevent aria-describedby broken reference in `comment_form()`
--------------------------+--------------------------------------
Reporter: afercia | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version:
Severity: normal | Resolution:
Keywords: | Focuses: accessibility, template
--------------------------+--------------------------------------
Description changed by afercia:
Old description:
> The `comment_form()` generates a complete commenting form, mainly used by
> themes.
>
> The email field markup has an `aria-describedby="email-notes"` attribute
> that targets a description. Actually the description is the default
> `comment_notes_before` argument and outputs the following HTML
> (simplified code):
>
> {{{
> <p class="comment-notes"><span id="email-notes">Your email address will
> not be published.</span></p>
> }}}
>
> However, it is possible to pass the `comment_notes_before` a completely
> different HTML (which may ''not'' contain the `email-notes` ID) or an
> empty string to completely omit the description. See for example the
> comment form on this page:
>
> https://andersnoren.se/themes/chaplin/2014/08/03/babela-armchair/
>
> It's understandable developers are misled: the `comment_form()` function
> allows to do this, while it should ensure semantic markup. I'd tend to
> think this is a core responsibility that can't be delegated to the
> developers attention to details.
>
> In these cases, the `aria-describedby` attribute points to a broken
> reference. This should be avoided because the attribute communicates user
> agents and assistive technologies there's a description but then the
> referenced description is missing. It will be flagged as failure by any
> accessibility automated checker tool and, most importantly, is
> potentially confusing for assistive technologies users.
>
> Related standard:
> https://www.w3.org/TR/WCAG21/#info-and-relationships
>
> Ideally, the `aria-describedby` attribute should be printed out only if
> there's a description and only if the targeted ID actually exists. One
> option could be checking for a non empty `comment_notes_before` and wrap
> an element with ID `email-notes` around its output.
New description:
The `comment_form()` generates a complete commenting form, mainly used by
themes.
The email field markup has an `aria-describedby="email-notes"` attribute
that targets a description. Actually the description is the default
`comment_notes_before` argument and outputs the following HTML (simplified
code):
{{{
<p class="comment-notes"><span id="email-notes">Your email address will
not be published.</span></p>
}}}
However, it is possible to pass the `comment_notes_before` a completely
different HTML (which may ''not'' contain the `email-notes` ID) or an
empty string to completely omit the description. See for example the
comment form on this page:
https://andersnoren.se/themes/chaplin/2014/08/03/babela-armchair/
It's understandable developers are misled: the `comment_form()` function
allows to do this, while it should ensure semantic markup. I'd tend to
think this is a core responsibility that can't be delegated to the
developers attention to details.
In these cases, the `aria-describedby` attribute points to a broken
reference. This should be avoided because the attribute communicates user
agents and assistive technologies there's a description but then the
referenced description is missing. It will be flagged as failure by any
accessibility automated checker tool and, most importantly, is potentially
confusing for assistive technologies users.
Related standard:
**WCAG Success Criterion 1.3.1 Info and Relationships**
https://www.w3.org/TR/WCAG21/#info-and-relationships
Ideally, the `aria-describedby` attribute should be printed out only if
there's a description and only if the targeted ID actually exists. One
option could be checking for a non empty `comment_notes_before` and wrap
an element with ID `email-notes` around its output.
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47975#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list