-
Notifications
You must be signed in to change notification settings - Fork 85
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
feat: forward compatibility with v9 on v-model
props/events
#6172
Conversation
cb00e86
to
98e720c
Compare
src/composables/useModelMigration.ts
Outdated
* @return {import('vue').WritableComputedRef} - model proxy | ||
*/ | ||
export function useModelMigration(oldModelName, oldModelEvent) { | ||
const vm = getCurrentInstance()!.proxy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 <[email protected]>
…heckboxRadioSwitch Signed-off-by: Grigorii K. Shartsev <[email protected]>
Signed-off-by: Grigorii K. Shartsev <[email protected]>
Signed-off-by: Grigorii K. Shartsev <[email protected]>
Signed-off-by: Grigorii K. Shartsev <[email protected]>
Signed-off-by: Grigorii K. Shartsev <[email protected]>
Signed-off-by: Grigorii K. Shartsev <[email protected]>
Signed-off-by: Grigorii K. Shartsev <[email protected]>
Signed-off-by: Grigorii K. Shartsev <[email protected]>
Signed-off-by: Grigorii K. Shartsev <[email protected]>
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?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested used in Talk components, do not expect the rest to break anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested some components, but reviewed code - looks sane!
🪄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on components existing in Talk ✅ all good
Code-wise ✅
☑️ Resolves
This PR adds forward compatibility with
next
(v9
) onv-model
props/eventsmodelValue
prop fallbacks to an old propupdate:modelValue
is emitted together with an old eventupdate:model-value
is emitted as well to use the new Vue 3 recommended event style in template compatible with Vue 2Implementation details:
useModelMigration
to create migration proxy that:model
proxy instead of old prop to get valuemodel
instead of$emit
an old eventprop
andevent
as well as define/updatemodel
optionv-model
in docs examplesScreenshots
Docs
required: true
📃 Components
:checked
+@update:checked
::value
+@update:value
::value
+@input
)::value
+@input
)::value
+@update:value
::value
+@update:value
)🏁 Checklist
next
requested with a Vue 3 upgrade