-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Vue drops value=""
from <button>
#6277
Comments
vue doesn't add the value attribute to the element if its empty .(edited) ( see #6277 (comment) for more correct analysis) <button id="a" value='' disabled=''></button> renders to <button id="a" disabled=''> and so the css selector of There are however workarounds, for this less common use case. for example <button :value.attr="''" ></button> which forced binding the attribute, and it can not be removed anymore based on value. |
Yeah, |
here is the reassessed relevant general logic vue follows. 1. if the attribute name exists as an element prop, set the element prop. in the case of the This is what creates the apparent inconsistency. for thankfully forcing setting as explicit attribute exists and can be used as the workaround. it can be fixed on vue side, by explicitly setting value prop, for empty string, even if the value is the same. |
I get this also with a hidden field: <input :name="name" value="" type="hidden" />
<input name="my_field" type="hidden"> Didn't use to do this under Vue 2. The <input name="my_field" value="" type="hidden"> |
fixed since v3.4.21 via #10416 |
Vue version
3.2.37
Link to minimal reproduction
SFC Playground
Steps to reproduce
Visit testcase
What is expected?
Both buttons should have a green outline (applied on
button[value]
)What is actually happening?
The button inside the Vue app does not have a
value
attribute after Vue renders.System Info
No response
Any additional comments?
This seems too basic to have gone undetected, so sorry if I'm missing something obvious!
The text was updated successfully, but these errors were encountered: