Skip to content

Commit

Permalink
Image inputs with alt text shouldn't flag for missing_form_label
Browse files Browse the repository at this point in the history
  • Loading branch information
pattonwebz committed Jun 28, 2024
1 parent b9f4ab7 commit f9976b9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions includes/rules/missing_form_label.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ function edac_rule_missing_form_label( $content, $post ) { // phpcs:ignore -- $p
if ( in_array( $field->getAttribute( 'type' ), [ 'submit', 'hidden', 'button', 'reset' ], true ) ) {
continue;
}

// Not an error if it's an image input with an alt.
if ( 'image' === $field->getAttribute( 'type' ) && ! empty( $field->getAttribute( 'alt' ) ) ) {
continue;
}

if ( ! ac_input_has_label( $field, $dom ) ) {
$errors[] = $field->outertext;
}
Expand Down

0 comments on commit f9976b9

Please sign in to comment.