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

fix(html-lang-valid): only run rule when attribute has value #3663

Conversation

thibaudcolas
Copy link
Contributor

@thibaudcolas thibaudcolas commented Sep 20, 2022

Depends on #3669. Closes issue #3624. This updates the rule’s selector as discussed so the rule is reported as inapplicable when encountering empty lang or xml:lang attributes.

It would be nice if this detail of the implementation was documented somewhere but I’m not sure where would be a good place.

For tests, I added another "applicability" test case similar to html-lang-valid virtual-rule – is inapplicable without lang or xml:lang. I also considered adding a test case to test/integration/full/html-lang-valid/html-lang-valid.js, however we’re not checking applicability in there currently, and it seems the only thing we could do is add another frame and check it isn’t in the result – so I decided to leave this out. Happy to revisit if needed.


This is failing currently in tests, with existing passes and violations not getting picked up by the new selector. I’m not entirely sure why – could be because of how Axe converts selectors to its own expression format but that’s just a guess.

@thibaudcolas thibaudcolas requested a review from a team as a code owner September 20, 2022 13:17
@thibaudcolas thibaudcolas changed the title Change html-lang-valid selector so the rule only applies when attrs have a value. Fix #3624 Change html-lang-valid selector so the rule only applies when lang has a value. Fix #3624 Sep 20, 2022
@thibaudcolas thibaudcolas marked this pull request as draft September 20, 2022 13:33
@straker
Copy link
Contributor

straker commented Sep 20, 2022

It looks like you've encountered a bug in our code. Digging into this it looks like when we try to match the not expression of [html=""], our matches code for attributes checks if the regex generated from css-parser matches (which it does). But it also checks to see if the value property is falsy, which in this case it is (value: ""), so the matches thinks the attribute matches, which then is negated with the not pseudo class causing the matcher to fail even though the attribute has a value. We'll need to fix this before we can merge this pr

@thibaudcolas
Copy link
Contributor Author

Thank you for looking into this @straker. I’m feeling out of my depth here so I’ll leave this as-is until someone else can devise a fix.

@straker
Copy link
Contributor

straker commented Sep 22, 2022

Have a pr that should fix the issue.

@thibaudcolas thibaudcolas force-pushed the 3624-configuration-inapplicable-html-lang-valid branch from 24c0701 to 8b4829b Compare September 24, 2022 04:26
@thibaudcolas thibaudcolas force-pushed the 3624-configuration-inapplicable-html-lang-valid branch from 8b4829b to eb04e60 Compare October 6, 2022 20:36
@thibaudcolas thibaudcolas force-pushed the 3624-configuration-inapplicable-html-lang-valid branch from eb04e60 to 95b2224 Compare October 6, 2022 22:54
@thibaudcolas thibaudcolas marked this pull request as ready for review October 6, 2022 22:55
@thibaudcolas
Copy link
Contributor Author

Rebased onto the latest develop, with the fix so this now seems to be working as expected. I believe this is now ready for review, though note I’ve only tested the change with the added unit test so far.

Copy link
Contributor

@straker straker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! We should also update the html-valid-lang integration tests to check for this. If you create two more iframes inside the frames dir, one using lang and the other for xml:lang and make the attributes empty, and then add the frames to the html-valid-lang.html file, that should be enough (since it shouldn't modify the passes/violation count of the test)

@straker
Copy link
Contributor

straker commented Nov 4, 2022

@thibaudcolas anything I can do to help with the pr?

@straker
Copy link
Contributor

straker commented Nov 22, 2022

@thibaudcolas I'll go ahead and add the tests so this can be reviewed and merged.

@straker straker changed the title Change html-lang-valid selector so the rule only applies when lang has a value. Fix #3624 fix(html-lang-valid): only run rule when attribute has value Nov 22, 2022
@straker straker dismissed their stale review November 22, 2022 16:58

Resolved

@WilcoFiers
Copy link
Contributor

[x] Reviewed for security

@straker straker merged commit 1a7eecb into dequelabs:develop Nov 29, 2022
@thibaudcolas
Copy link
Contributor Author

Thank you for picking this up! I had a busy couple months and wouldn’t have been able to get to this until now, it’s great to see it having gone through.

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

Successfully merging this pull request may close these issues.

3 participants