-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Binding boolean attributes have unexpected result in vue-next #1173
Comments
@Yukon123 I noticed that you refer to Vue 2 docs here, just to make sure: what version of Vue you are using in the examples above? Attribute coercion behavior changed in Vue 3, here is an overview: https://v3.vuejs.org/guide/migration/attribute-coercion.html#attribute-coercion-behavior |
@NataliaTepluhina Thanks a lot. I reading Vue3 document but test in Vue2 environment.That its why my confuse happened. Thanks again for point that. |
@NataliaTepluhina I have changed my operating environment to Vue3.Still, there are some strange things happened on binding boolean attributes.In that case,I edit and reopen the issue.I would be very grateful if you could check it out. |
When setting the attributes of a DOM element, Vue first checks whether there is a property on the element with the same name as the attribute. If there is, it will assign the value to the property rather than the attribute. In some cases, the browser will update the attribute when the property is assigned. In other cases, such as For most attributes it won't matter, as setting the property achieves the desired result. If you need to force the creation of an actual attribute you can use The problem with I've got a fix for this locally. I still need to update the SSR handling but once I've got that working I'll put in a PR. |
Thanks for the reply,the |
This should now be fixed. |
Hi there.
My confusion lies in the following two points :
1.Readonly is a boolean attributes,but didn't performs like the Docs present.
2.Checked is a boolean attributes,Although its value is true, it is still not mounted in html element.
Ps: The following example is run in the Vue3 environment.
The Vue3 docs says :
Another description of binding boolean attributes is
but it just about treating enumerated attributes as normal non-boolean attributes,and no refer to this issue.
MDN says
In My Test
If the
readonly
have falsy values like 0 , -0 , NaN , It will also be included. Result in browsers
The other example in boolean attributes (e.g.
required
,disabled
) were perform just like the doc present ,the attribute will be omitted with falsy values(exclude empty string) .Another example
In the views it's correct,it shows one radio is checked and the other is unchecked.
But in element there has no attribute called 'checked'.
The text was updated successfully, but these errors were encountered: