File tree 2 files changed +10
-10
lines changed
2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -153,10 +153,10 @@ describe('useModel', () => {
153
153
154
154
const compRender = vi . fn ( )
155
155
const Comp = defineComponent ( {
156
- props : [ 'fooBar ' ] ,
157
- emits : [ 'update:fooBar ' ] ,
156
+ props : [ 'foo-bar ' ] ,
157
+ emits : [ 'update:foo-bar ' ] ,
158
158
setup ( props ) {
159
- foo = useModel ( props , 'fooBar ' )
159
+ foo = useModel ( props , 'foo-bar ' )
160
160
return ( ) => {
161
161
compRender ( )
162
162
return foo . value
@@ -192,10 +192,10 @@ describe('useModel', () => {
192
192
193
193
const compRender = vi . fn ( )
194
194
const Comp = defineComponent ( {
195
- props : [ 'fooBar ' ] ,
196
- emits : [ 'update:fooBar ' ] ,
195
+ props : [ 'foo-bar ' ] ,
196
+ emits : [ 'update:foo-bar ' ] ,
197
197
setup ( props ) {
198
- foo = useModel ( props , 'fooBar ' )
198
+ foo = useModel ( props , 'foo-bar ' )
199
199
return ( ) => {
200
200
compRender ( )
201
201
return foo . value
Original file line number Diff line number Diff line change @@ -28,22 +28,22 @@ export function useModel(
28
28
return ref ( ) as any
29
29
}
30
30
31
- if ( __DEV__ && ! ( i . propsOptions [ 0 ] as NormalizedProps ) [ name ] ) {
31
+ const camelizedName = camelize ( name )
32
+ if ( __DEV__ && ! ( i . propsOptions [ 0 ] as NormalizedProps ) [ camelizedName ] ) {
32
33
warn ( `useModel() called with prop "${ name } " which is not declared.` )
33
34
return ref ( ) as any
34
35
}
35
36
36
- const camelizedName = camelize ( name )
37
37
const hyphenatedName = hyphenate ( name )
38
- const modifiers = getModelModifiers ( props , name )
38
+ const modifiers = getModelModifiers ( props , camelizedName )
39
39
40
40
const res = customRef ( ( track , trigger ) => {
41
41
let localValue : any
42
42
let prevSetValue : any = EMPTY_OBJ
43
43
let prevEmittedValue : any
44
44
45
45
watchSyncEffect ( ( ) => {
46
- const propValue = props [ name ]
46
+ const propValue = props [ camelizedName ]
47
47
if ( hasChanged ( localValue , propValue ) ) {
48
48
localValue = propValue
49
49
trigger ( )
You can’t perform that action at this time.
0 commit comments