Make WordPress Core


Ignore:
Timestamp:
09/11/2019 01:50:23 AM (6 years 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/tests/phpunit/tests/comment/commentForm.php

    r43531 r46090  
    1414            'label_submit' => 'foo-label',
    1515        );
     16
    1617        $form = get_echo( 'comment_form', array( $args, $p ) );
    1718
     
    3132            'submit_button' => '<input name="custom-%1$s" type="submit" id="custom-%2$s" class="custom-%3$s" value="custom-%4$s" />',
    3233        );
     34
    3335        $form = get_echo( 'comment_form', array( $args, $p ) );
    3436
     
    4749            'submit_field' => '<p class="my-custom-submit-field">%1$s %2$s</p>',
    4850        );
     51
    4952        $form = get_echo( 'comment_form', array( $args, $p ) );
    5053
     
    9598            ),
    9699        );
     100
    97101        $form = get_echo( 'comment_form', array( $args, $p ) );
    98102
     
    101105        $this->assertRegExp( '|<p class="comment\-form\-cookies\-consent">.*?</p>|', $form );
    102106    }
     107
     108    /**
     109     * @ticket 47975
     110     */
     111    public function test_aria_describedby_email_notes_should_not_be_added_if_no_email_notes() {
     112        $p = self::factory()->post->create();
     113
     114        $form_with_aria = get_echo( 'comment_form', array( array(), $p ) );
     115
     116        $this->assertContains( 'aria-describedby="email-notes"', $form_with_aria );
     117
     118        $args = array(
     119            'comment_notes_before' => '',
     120        );
     121
     122        $form_without_aria = get_echo( 'comment_form', array( $args, $p ) );
     123
     124        $this->assertNotContains( 'aria-describedby="email-notes"', $form_without_aria );
     125    }
    103126}
Note: See TracChangeset for help on using the changeset viewer.