Skip to content

Commit

Permalink
fix(vue): improve v-model integration for Vue 3.1.0+ (ionic-team#23420)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamdebeasi authored Jun 4, 2021
1 parent 82cfa55 commit f008628
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
14 changes: 7 additions & 7 deletions core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@rollup/plugin-node-resolve": "^8.4.0",
"@rollup/plugin-virtual": "^2.0.3",
"@stencil/sass": "1.3.2",
"@stencil/vue-output-target": "^0.4.2",
"@stencil/vue-output-target": "^0.4.3",
"@types/jest": "^26.0.20",
"@types/node": "^14.6.0",
"@types/puppeteer": "5.4.3",
Expand Down
10 changes: 9 additions & 1 deletion packages/vue/src/vue-component-lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit f008628

Please sign in to comment.