Skip to main content

is_valid_aria_role

Function is_valid_aria_role 

Source
pub fn is_valid_aria_role(role: &str, element: &ElementRef<'_>) -> bool
Expand description

Check if an ARIA role is valid for a given element.

§Arguments

  • role - The ARIA role to validate.
  • element - The HTML element to validate.

§Returns

  • bool - Whether the role is valid for the element.

§Examples

use html_generator::utils::is_valid_aria_role;
use scraper::{Html, Selector};

let dom = Html::parse_fragment(r#"<a href="/x">link</a>"#);
let sel = Selector::parse("a").unwrap();
let a = dom.select(&sel).next().unwrap();
assert!(is_valid_aria_role("link", &a));
assert!(!is_valid_aria_role("checkbox", &a));