feat: forward compatibility with v9 on v-model props/events#6172
Conversation
cb00e86 to
98e720c
Compare
| * @return {import('vue').WritableComputedRef} - model proxy | ||
| */ | ||
| export function useModelMigration(oldModelName, oldModelEvent) { | ||
| const vm = getCurrentInstance()!.proxy |
There was a problem hiding this comment.
I am not sure here, I had issues with this in past (accessing the proxy inside of the setup function).
Not sure if it was something in my code but for me I had to move the proxy access into the computed functions
There was a problem hiding this comment.
We've been using similar approach for several major versions already in Talk for Vuex Store (useStore.js) in script setup components and composables, and so far didn't caught any errors with it.
Maybe some guard here with debug information would be safe (so if anyone encounters it, we can identify the reason)
There was a problem hiding this comment.
@susnux This is not possible. This function returns either null or { proxy: instance }.
https://github.com/vuejs/vue/blob/main/src/v3/currentInstance.ts#L13
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
…heckboxRadioSwitch Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
98e720c to
04e17bb
Compare
v-model props/events
|
I understand this PR is quite huge. Maybe you can review at least some of them and check here?
|
Antreesy
left a comment
There was a problem hiding this comment.
Tested used in Talk components, do not expect the rest to break anything
susnux
left a comment
There was a problem hiding this comment.
Tested some components, but reviewed code - looks sane!
|
🪄 |
DorraJaouad
left a comment
There was a problem hiding this comment.
Tested on components existing in Talk ✅ all good
Code-wise ✅
| input: passthru ? $listeners.input : noop, | ||
| 'update:modelValue': passthru ? $listeners['update:modelValue'] : handleInput, | ||
| 'update:model-value': passthru ? $listeners['update:model-value'] : noop, |

☑️ Resolves
This PR adds forward compatibility with
next(v9) onv-modelprops/eventsmodelValueprop fallbacks to an old propupdate:modelValueis emitted together with an old eventupdate:model-valueis emitted as well to use the new Vue 3 recommended event style in template compatible with Vue 2Implementation details:
useModelMigrationto create migration proxy that:modelproxy instead of old prop to get valuemodelinstead of$emitan old eventpropandeventas well as define/updatemodeloptionv-modelin docs examplesScreenshots
Docs
required: true📃 Components
:checked+@update:checked::value+@update:value::value+@input)::value+@input)::value+@update:value::value+@update:value)🏁 Checklist
nextrequested with a Vue 3 upgrade