-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(aria): use aria metadata to find equivalent HTML element #4495
Conversation
@@ -1,22 +0,0 @@ | |||
use biome_aria_metadata::{IsoCountries, IsoLanguages, ISO_COUNTRIES, ISO_LANGUAGES}; | |||
use std::str::FromStr; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this code in the biome_aria_metadata
crate.
9756b1b
to
5445e56
Compare
<div role="blockquote" ></div> | ||
<div role="associationlist" ></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The role was part of the Aria 1.2 draft and was eventually removed before the stabilization of Aria 1.2.
<div role="p" ></div> | ||
<div role="aside" ></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These roles don't exist.
<div role="graphics-document" ></div> | ||
<div role="graphics-object" ></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related concepts for these two roles are missing. I plan to add them back in a future PR.
CodSpeed Performance ReportMerging #4495 will not alter performanceComparing Summary
|
<div role="dialog" ></div> | ||
|
||
<div role="cell" ></div> | ||
<div role="columnheader" ></div> | ||
<div role="definition" ></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related concepts for these two roles are missing. I plan to add them back in a future PR.
5445e56
to
fa97efa
Compare
fa97efa
to
a823d3c
Compare
Summary
Part of #4241.
This PR removes the remaining role definitions from
biome_aria
.I noticed some errors: we had invalid roles
p
andaside
.Also we had a never stabilized role
associationlist
. It was part of ARIA 1.2 draft and was finally removed before is stabilization. Some MDN docs still have some documentation for this role.I refactored
is_not_interactive_element
to useget_implicit_role
instead of traversing all roles looking for a role with the current element as concept.This allowed me to identify some missing elements in
get_implicit_role
.This also makes the code simpler to read and to understand.
I added an exception for
a
andarea
because our previous code considered them as interactive, and our current code that relies onget_implicit_role
flagged them as non-interactive ifhref
is not set.Taking a look at the implementation of JSX A11y for interactive/non-interactive roles,
I noticed that some roles are neither interactive nor non-interactive.
This is the case of the
toolbar
role.Thus, I created the
AriaRole::is_non_interactive
method.In contrast to the implementation of JSX A11y, I didn't add
generic
because it created many regressions in our test suite.Some of our rules have not the same test suite as JSX A11y and some of our rules have slight or subtle behavioral differences.
This makes it hard to detect if a change is expected or not.
Thus, I tried to avoid regression in our current test suite.
I think we will have to review every rule and also the implementation of JSX A11y because I noticed that there are numerous hacks and limitations in their code base.
As a side note, JSX A11y uses also the axobject-query NPM package that provides data from Chrome AXObject. This complements the data from ARIA query and is more browser-centered. We will have to investigate if we should/want to use this extra source of data to determine if an element is interactive or non-interactive.
I added
std::fmt::Display
impl forHtmlElementInstance
. This allowed me to drastically reduce the complexity of the implementation of theuseSematicElements
rule.Test Plan