-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Boolean v-model
doesn't default to undefined
when not set
#9882
Comments
This is documented behavior so 1) it's not a bug and 2) will not be changed in Vue 3.
|
I know it's documented but I think the use-case for boolean props is different than boolean |
You can define a default in |
@CernyMatej This has been a very-long-standing error in Vue, but it's probably too risky to correct it now. |
Vue version
3.3.13
Link to minimal reproduction
https://play.vuejs.org/#eNp9UstugzAQ/BXLF1opj0NuEYnUVDm0Uh9qevSFwIaSGtuyF5oK8e9dm0BTNeLE7O4wO7PQ8DtjZnUFfMljl9rCIJOJyleCoxOcOcDKrIVKtXLI3JPOQLIVy+BQKAhV7NAWKl/fRB2Ibnv2/hp7r7WERBH9jDw/nneraREVCKWRCQJVjMVZUQdA0BvxgLFdWMXqaRlWKE3eAJesaRh+G9CH3mrbsimLqD3U0Vls7tX+CW86U2PK51iD8lD/UfbPzno8vwjEJ3RXOs+hyGdHpxWdvfFkwVNdmkKCfTFY0PkEp52doOCJlPrrMfTQVjDp++kHpJ9X+kd38j3BXy04sDUIPswwsTlgN97unuFEeBhS6EoSe2T4Bk7LynvsaJtKZWT7ghfcPpRGW6SP9O62JwTl+lDeqGe2gS84/Xv3I9F/7S5mi/CeUC1vfwBRQuR4
Steps to reproduce
v-model
when using the component in the template of a parent componentWhat is expected?
Since all other types have
undefined
value when they're not set, I would expect aboolean
v-model to behave the same.I assume the root cause of this problem is that normal boolean props are converted to
false
when not set.I can see why this behavior might be desired for props in certain situations. However, it creates issues in detecting whether a v-model has been set. Therefore, I think it would be better to have consistency in prop behavior.
What is actually happening?
A
v-model
ofboolean
type has a value offalse
when not set, instead ofundefined
.System Info
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: