-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
feat: add a11y autocomplete-valid
#8520
Conversation
@cruessler is attempting to deploy a commit to the Svelte Team on Vercel. A member of the Team first needs to authorize it. |
Thanks for researching that the rule is deprecated in axe-core! Given that axe-core is quite strict in other places, I'd say eslint-jsx-a11y just hasn't caught up on that one yet. We therefore shouldn't implement this, so I'm closing this issue, sorry. Still congratulations on your first Svelte PR! |
|
I'm sorry, I misunderstood then. I then suggest to remove the parts from the PR that are testing for Btw I saw that you added quite a few new tokens, it may be that they are already part of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few comments, hoping to provide a bit of context for the review.
'impp' | ||
]); | ||
|
||
export function is_valid_autocomplete(type: null | true | string, autocomplete: null | true | string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The types come from the inferred return type of get_static_value
. I was unsure whether to add them, but wanted to be cautious in order not to miss edge cases.
src/compiler/compile/utils/a11y.ts
Outdated
const input_wears_autofill_anchor_mantle = normalized_type === 'hidden'; | ||
const input_wears_autofill_expectation_mantle = !input_wears_autofill_anchor_mantle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The language comes from the spec. Given that axe-core
’s implementation does not implement this part of the spec, do you want me to remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly do you mean by that? If it's about simplifying this to always allow on and off, then yes, let's relax this
@@ -223,3 +224,111 @@ export function is_semantic_role_element(role: ARIARoleDefinitionKey, tag_name: | |||
} | |||
return false; | |||
} | |||
|
|||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute | |||
const address_type_tokens = new Set(['shipping', 'billing']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not able to find any of the following tokens in either axobject-query
or aria-query
.
<input type="text" autocomplete /> | ||
<input type="hidden" autocomplete="off" /> | ||
<input type="hidden" autocomplete="on" /> | ||
<input type="text" autocomplete="" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
axe-core
does not have this as an error, but does not apply the rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say let's relax this then to allow the empty and boolean value. We also need a test that checks if it succeeds if a synamic value is given, like autocomplete={foo}
<input type="text" autocomplete="section-blue shipping street-address" /> | ||
|
||
<!-- INVALID --> | ||
<input type="text" autocomplete /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
axe-core
does not have this as a test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This has been released in 3.59.0 - thank you! |
why this error when autocomplete as value ? |
This PR adds validation to the
autocomplete
attribute for<input>
elements, similar to the ESLint rulejsx-a11y/autocomplete-valid
. It is related to #820.The implementation generally follows the implementation in
axe-core
.This PR currently only works for
<input>
elements. According to the spec, these rules also apply to<textarea>
and<select>
elements, but the corresponding ESLint rule only applies to<input>
elements.This PR is quite strict in validating the
autocomplete
value, because I tried to follow the spec as much as possible.axe-core
which is what the ESLint rule uses under the hood, dropped support for checking for approriate types at some point. See dequelabs/axe-core#2912 and dequelabs/axe-core#2917. I saw that you recently relaxed checks on a different rule, and I was wondering whether my PR is too strict. I’m not deeply familiar with A11y, so any guidance is welcome!I got most of the test cases from ESLint and
axe-core
. I was not sure whether it made sense to add more test cases. Let me know whether you want any changes in that regard!