-
-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(aria): generate role metadata (#4488)
- Loading branch information
Showing
26 changed files
with
751 additions
and
1,374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} | ||
} |
Oops, something went wrong.