WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/11/2019 01:50:23 AM (17 months ago)
Author:
SergeyBiryukov
Message:

Accessibility: Comments: In comment_form(), remove aria-describedby attribute from the email field if there's no associated description in the comment_notes_before argument.

The attribute is meant to communicate to user agents and assistive technologies that the element has a description. If the referenced description is missing, it will be flagged as failure by any automated accessibility checker tool and, most importantly, is potentially confusing for assistive technologies users.

Props afercia, joedolson, dinhtungdu, donmhico, SergeyBiryukov.
Fixes #47975.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r46088 r46090  
    24292429    $args = array_merge( $defaults, $args );
    24302430
     2431    // Remove aria-describedby from the email field if there's no associated description.
     2432    if ( false === strpos( $args['comment_notes_before'], 'id="email-notes"' ) ) {
     2433        $args['fields']['email'] = str_replace(
     2434            ' aria-describedby="email-notes"',
     2435            '',
     2436            $args['fields']['email']
     2437        );
     2438    }
     2439
    24312440    /**
    24322441     * Fires before the comment form.
     
    25102519            endif;
    25112520
    2512             // Prepare an array of all fields, including the textarea
     2521            // Prepare an array of all fields, including the textarea.
    25132522            $comment_fields = array( 'comment' => $args['comment_field'] ) + (array) $args['fields'];
    25142523
Note: See TracChangeset for help on using the changeset viewer.