Skip to content

Commit

Permalink
refactor(aria): generate role metadata (#4488)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos authored Nov 8, 2024
1 parent 3fe9193 commit 27b93c2
Show file tree
Hide file tree
Showing 26 changed files with 751 additions and 1,374 deletions.
36 changes: 0 additions & 36 deletions crates/biome_aria/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,7 @@
use std::str::FromStr;

pub mod iso;
mod macros;
pub mod roles;

pub use biome_aria_metadata::{AriaAttribute, AriaValueType};
pub(crate) use roles::AriaRoleDefinition;
pub use roles::AriaRoles;

/// It checks if an ARIA property is valid
///
/// ## Examples
///
/// ```
/// use biome_aria::is_aria_property_valid;
///
/// assert!(!is_aria_property_valid("aria-blabla"));
/// assert!(is_aria_property_valid("aria-checked"));
/// ```
pub fn is_aria_property_valid(property: &str) -> bool {
AriaAttribute::from_str(property).is_ok()
}

#[cfg(test)]
mod test {
use crate::roles::AriaRoles;

#[test]
fn property_is_required() {
let roles = AriaRoles;

let role = roles.get_role("checkbox");

assert!(role.is_some());

let role = role.unwrap();

assert!(role.is_property_required("aria-checked"));
assert!(!role.is_property_required("aria-sort"));
assert!(!role.is_property_required("aria-bnlabla"));
}
}
Loading

0 comments on commit 27b93c2

Please sign in to comment.