mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
fix(vue): improve v-model integration for Vue 3.1.0+ (#23420)
This commit is contained in:
@ -121,9 +121,17 @@ export const defineContainer = <Props>(name: string, componentProps: string[] =
|
||||
};
|
||||
|
||||
if (modelProp) {
|
||||
/**
|
||||
* Starting in Vue 3.1.0, all properties are
|
||||
* added as keys to the props object, even if
|
||||
* they are not being used. In order to correctly
|
||||
* account for both value props and v-model props,
|
||||
* we need to check if the key exists for Vue <3.1.0
|
||||
* and then check if it is not undefined for Vue >= 3.1.0.
|
||||
*/
|
||||
propsToAdd = {
|
||||
...propsToAdd,
|
||||
[modelProp]: props.hasOwnProperty('modelValue') ? props.modelValue : modelPropValue
|
||||
[modelProp]: props.hasOwnProperty(MODEL_VALUE) && props[MODEL_VALUE] !== undefined ? props.modelValue : modelPropValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user