vue
vue copied to clipboard
`$forceUpdate` do not update checked status of checkbox-
Version
2.6.10
Reproduction link
https://jsfiddle.net/ahy27vu3/
Steps to reproduce
- input[type="text"] value is forced to
''
, which is controlled completely - input[type="checkbox"] checked does not work
What is expected?
input[type="checkbox"] checked is forced to false
What is actually happening?
input[type="checkbox"] checked keep the value last entered
Maybe this is designed on purpose,Could you please explain why? https://github.com/vuejs/vue/blob/dev/src/platforms/web/runtime/modules/dom-props.js#L67 https://github.com/vuejs/vue/blob/dev/src/platforms/web/runtime/modules/dom-props.js#L42
Please see https://github.com/vuejs/vue/issues/9535 and https://github.com/vuejs/vue/issues/9340
@posva This issue has nothing to do with micro/macro task
@posva I believe what @xiaodemen want is to implement a “fully controlled” checkbox.
It is related to micro/macro task though as it used to work on 2.5
I'm realising the $forceUpdate
doesn't work anymore though and that is a problem
@posva It is not related to micro/macro task, see: https://github.com/vuejs/vue/blob/v2.6.0/src/platforms/web/runtime/modules/dom-props.js#L45
You're probably both "right". The change that you link to, @xiaodemen, was done because it was expected that the check for "checked" should no longer be necessary after we did the microtaks changes in 2.6. But appearantly that's not always the caase.
I know this issue is pretty old, and it might even have gotten fixed in Vue 3, but is there any chance it will be looked at at some point? 😇
I've faced with the similar issue. $forceUpdate
doesn't work if element (even text input) is wrapped inside custom component.
Minimal example: https://sfc.vuejs.org/#eNqNVMGOmzAQ/ZVZVIlE2mD1miYrrXJpq17bXnyhMCRsjY08A2kV8e8d24Qke2oOgbHH772Z5+GSvfZ9MQ6YbbMdVb7t+UXbtuudZzi4rofGuw7yQoUgJOaftAXQFv/EnBqbcjAMl7BaSY6zaJm2aQEixnN4neJ/XXK5Wl83PfLg7TXSPJZmwC3kn9EYBz+dN/VTnjanSJtAAs3AWM8kmlsr8Y90eAYDOCLfmO7Y+NRSEZkiZASPsOFHcijuPZxUCg4DsTTCuGNbATtoWsPoobS1ch46V7fNXxhIlqKY29kbHewhPgt239wZ/aEkXK0Lj70pK1wprUkdnyHP14swgLaBJAie9vs7sAd9UWHjfIVS5MajrUWHiCQWQ4F6gaf77AjzIR743oslIuOOclraMrc+2J2aFFzYqeWeSMDYiXxGiQB2p48vVxsuqRExhGnaKdmLOX18ALwaAwZZukhQehRX7YhebA3KTWgQVNKh0OK5hJjmsXMj1kXEUglMML+KP4kRVveVwdn537ReMlPKuBHH0Ox1dhOpsyvWl5jTWmprkZWMX672O/jaIdmcI82NJdz6ucz/YIyzJa87tXQze87SEG66si/eyFkZ0HTb5w3S2XLZdSaDGWKdnZh72ipFTRWm9Y0K549K3go/WG47LJC6zS/vznJXBVhn0VuxViivMx4+Bo/G1u0IlSmJpIDUkVm87JFxDGouRRLfVTL9A4ovbM4=