Skip to main content

audit

Function audit 

Source
pub fn audit(node: &Node) -> Vec<A11yIssue>
Expand description

Finds accessibility problems in a subtree.

The rules are the ones Winged-Swift’s ROADMAP.md lists under “Quality”:

  • <img> without an alt attribute
  • <button> with neither text nor an aria-label
  • <iframe> without a title
  • <a> with no accessible name
  • <input> with neither an aria-label nor an id a <label> could point at

This is a linter, not a guarantee: it cannot tell whether an alt is useful, only whether it exists.

§Examples

use winged_rust::prelude::*;
use winged_rust::accessibility::audit;

let good = image("/a.png", "A cat");
assert!(audit(&good.clone().into()).is_empty());

let bad = Node::from(img().attr("src", "/a.png"));
assert_eq!(audit(&bad).len(), 1);