Skip to content

Commit f008628

Browse files
authored
fix(vue): improve v-model integration for Vue 3.1.0+ (#23420)
1 parent 82cfa55 commit f008628

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

core/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@rollup/plugin-node-resolve": "^8.4.0",
4242
"@rollup/plugin-virtual": "^2.0.3",
4343
"@stencil/sass": "1.3.2",
44-
"@stencil/vue-output-target": "^0.4.2",
44+
"@stencil/vue-output-target": "^0.4.3",
4545
"@types/jest": "^26.0.20",
4646
"@types/node": "^14.6.0",
4747
"@types/puppeteer": "5.4.3",

packages/vue/src/vue-component-lib/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,17 @@ export const defineContainer = <Props>(name: string, componentProps: string[] =
121121
};
122122

123123
if (modelProp) {
124+
/**
125+
* Starting in Vue 3.1.0, all properties are
126+
* added as keys to the props object, even if
127+
* they are not being used. In order to correctly
128+
* account for both value props and v-model props,
129+
* we need to check if the key exists for Vue <3.1.0
130+
* and then check if it is not undefined for Vue >= 3.1.0.
131+
*/
124132
propsToAdd = {
125133
...propsToAdd,
126-
[modelProp]: props.hasOwnProperty('modelValue') ? props.modelValue : modelPropValue
134+
[modelProp]: props.hasOwnProperty(MODEL_VALUE) && props[MODEL_VALUE] !== undefined ? props.modelValue : modelPropValue
127135
}
128136
}
129137

0 commit comments

Comments
 (0)