const compRender = vi.fn()
const Comp = defineComponent({
- props: ['fooBar'],
- emits: ['update:fooBar'],
+ props: ['foo-bar'],
+ emits: ['update:foo-bar'],
setup(props) {
- foo = useModel(props, 'fooBar')
+ foo = useModel(props, 'foo-bar')
return () => {
compRender()
return foo.value
const compRender = vi.fn()
const Comp = defineComponent({
- props: ['fooBar'],
- emits: ['update:fooBar'],
+ props: ['foo-bar'],
+ emits: ['update:foo-bar'],
setup(props) {
- foo = useModel(props, 'fooBar')
+ foo = useModel(props, 'foo-bar')
return () => {
compRender()
return foo.value
return ref() as any
}
- if (__DEV__ && !(i.propsOptions[0] as NormalizedProps)[name]) {
+ const camelizedName = camelize(name)
+ if (__DEV__ && !(i.propsOptions[0] as NormalizedProps)[camelizedName]) {
warn(`useModel() called with prop "${name}" which is not declared.`)
return ref() as any
}
- const camelizedName = camelize(name)
const hyphenatedName = hyphenate(name)
- const modifiers = getModelModifiers(props, name)
+ const modifiers = getModelModifiers(props, camelizedName)
const res = customRef((track, trigger) => {
let localValue: any
let prevEmittedValue: any
watchSyncEffect(() => {
- const propValue = props[name]
+ const propValue = props[camelizedName]
if (hasChanged(localValue, propValue)) {
localValue = propValue
trigger()