tomusborne / generatepress

452 stars 89 forks source link

prohibited aria-label usage #555

Closed Trott closed 1 year ago

Trott commented 1 year ago

Description

The following line is a bug and should be commented out/removed:

https://github.com/tomusborne/generatepress/blob/a4b04b12e1ad6c88c6109f23f196d61895f3d74b/inc/class-html-attributes.php#L290

This attribute gets applied to a <header> element. From https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/banner_role:

By default, the HTML's <header> element has an identical meaning to the banner landmark, unless it is a descendant of <aside>, <article>, <main>, <nav>, or <section>, at which point <header> exposes a generic role, and not the equivalent of the site-wide banner.

Since this <header> element is a child of an <article> element, it has the generic role.

The generic role cannot have an aria-label attribute. From https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/generic_role:

Because the generic role is nameless, the aria-labelledby and aria-label attributes are prohibited.

Steps to reproduce

  1. Run a site with GeneratePress.

Actual behavior

<header> element contained within an <article> element has an aria-label attribute.

Expected behavior

<header> element contained within an <article> element does not have an aria-label attribute.


References

JeanPaiva commented 1 year ago

Thank you @Trott we will look into this.