Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
feat(rome_js_analyzer): rule noNoninteractiveElementToInteractiveRole
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Dec 7, 2022
1 parent df86e5e commit bdd63f2
Show file tree
Hide file tree
Showing 15 changed files with 571 additions and 16 deletions.
40 changes: 40 additions & 0 deletions crates/rome_aria/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,44 @@ macro_rules! define_role {
}
}
};
( $( #[doc = $doc:literal] )+ $id:ident {
PROPS: $p_value:expr,
ROLES: $r_value:expr,
CONCEPTS: $c_value:expr,
}) => {
$( #[doc = $doc] )*
#[derive(Debug)]
struct $id;

impl $id {
const PROPS: &[(&'static str, bool)] = &$p_value;
const ROLES: &[&'static str] = &$r_value;
const CONCEPTS: &'static [(&'static str, &'static [(&'static str, &'static str)])] =
$c_value;
}

impl $crate::AriaRoleDefinition for $id {
fn properties<'a>(&self) -> std::slice::Iter<'a, (&str, bool)> {
$id::PROPS.iter()
}

fn roles<'a>(&self) -> std::slice::Iter<'a, &str> {
$id::ROLES.iter()
}
}

impl AriaRoleDefinitionWithConcepts for $id {
fn concepts_by_element_name<'a>(
&self,
element_name: &str,
) -> ElementsAndAttributes<'a> {
for (concept_name, _attributes) in Self::CONCEPTS {
if *concept_name == element_name {
return Some(Self::CONCEPTS.iter());
}
}
None
}
}
};
}
Loading

0 comments on commit bdd63f2

Please sign in to comment.