-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Bind boolean values to accessibility attributes #7422
Comments
If your values are always booleans, you can just do |
What if Is there potential for this behaviour to change for v3? |
@yyx990803 Is this documented in the vue Docs anywhere? I have tried to search for it but can't find any mention of this. Thanks. |
I agree that this could be made explicit in the docs. It's just a matter of the binding value (which generally looks like a string) actually being an expression. Doesn't help that you can actually get away with doing
The last sentence could add the value of |
What problem does this feature solve?
As you know, Vue currently removes HTML attributes bound to a boolean that evaluates to false.
Currently
<div :checked="false"></div>
renders as<div></div>
. Perfect.However, this does not work well for aria attributes. Per spec, many aria attributes need to have values set to
false
for screen readers.Ideally
<div :aria-expanded="false"></div>
renders to<div aria-expanded="false"></div>
This fiddle demonstrates the desired output and my current workaround.
While
:aria-expanded="expanded ? expanded : 'false'"
works, it gets messy with multiple aria attributes. I know I could also usestrings
, but that feels even messier and more hackish to me.What does the proposed API look like?
The easiest way I can think of fixing this is with a
.boolean
Modifier.<div :aria-expanded.boolean="falseBool"></div>
renders to<div aria-expanded="false"></div>
Thoughts or guidance?
The text was updated successfully, but these errors were encountered: