Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule H44 not implmented properly: #4

Closed
emonidi opened this issue Mar 17, 2024 · 4 comments
Closed

Rule H44 not implmented properly: #4

emonidi opened this issue Mar 17, 2024 · 4 comments

Comments

@emonidi
Copy link
Contributor

emonidi commented Mar 17, 2024

The WCAG rule H44 says:
Label found without a "for" attribute, and therefore not explicitly associated with a form control.

In the wcag_rule_map.rs on line 418 in the implementation of the rule the code is as follows:

Rule::new(Techniques::H44.into(), IssueType::Error, Principle::Perceivable, Guideline::Adaptable, "1", |nodes, _auditor| {
                    let mut valid = true;
                    let mut elements = Vec::new();

                    for ele in nodes {
                        match ele.0.attr("for") {
                            Some(s) => {
                                let selector = unsafe { Selector::parse(&("#".to_string() + &s)).unwrap_unchecked() };
                                let root_tree = ele.0.tree().root();

                                match ElementRef::new(root_tree) {
                                    t => {
                                        let e = t.select(&selector);

                                        if e.count() == 0 {
                                            valid = false;
                                            elements.push(get_unique_selector(&ele.0))
                                        }
                                    }
                                }
                            }
                            _ => ()
                        }
                    }

                    Validation::new(valid, "NonExistent", elements, Default::default()).into()
                })

The way I read it is the it finds a for element it will do a validation. If a for element is missing it will just continue with no error.
I believe that the behavior shuold be that if there is no for attribute it should check for aria-label or if there is text in this label in order to properly cary out the validation.

@j-mendez
Copy link
Contributor

Correct, looks like the fallback needs to be handled. I can add this in if you did not already start on the fix. Thanks

@emonidi
Copy link
Contributor Author

emonidi commented Mar 17, 2024

Thanks for your fast response I am still not feeling confident in my rust abilities although I like this project very much. If you don't mind to add it I would be gratefull. In the mean time I am preparing a PR for an error on missing alt on and tangs, just to get a feel of the project.

@j-mendez
Copy link
Contributor

Thanks for your fast response I am still not feeling confident in my rust abilities although I like this project very much. If you don't mind to add it I would be gratefull. In the mean time I am preparing a PR for an error on missing alt on and tangs, just to get a feel of the project.

Sounds good. I should be able to get to it shortly.

@j-mendez
Copy link
Contributor

@emonidi validation to check for aria-label -> text -> check for incorrect labels now applied. This made sense to me since browsers are now becoming more resilient to handle the errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants