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 12, 2022
1 parent 4418666 commit d107878
Show file tree
Hide file tree
Showing 15 changed files with 610 additions and 45 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,6 +23,46 @@ 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
}
}
};
}

#[macro_export]
Expand Down
Loading

0 comments on commit d107878

Please sign in to comment.