fix(v-model/emit): update:camelCase events should trigger kebab case equivalent

close #656
This commit is contained in:
Evan You
2020-01-26 14:13:55 -05:00
parent 48152bc88e
commit 2837ce8428
2 changed files with 33 additions and 2 deletions

View File

@@ -25,7 +25,8 @@ import {
NO,
makeMap,
isPromise,
isArray
isArray,
hyphenate
} from '@vue/shared'
import { SuspenseBoundary } from './components/Suspense'
import { CompilerOptions } from '@vue/compiler-core'
@@ -221,7 +222,11 @@ export function defineComponentInstance(
emit: (event, ...args): any[] => {
const props = instance.vnode.props || EMPTY_OBJ
const handler = props[`on${event}`] || props[`on${capitalize(event)}`]
let handler = props[`on${event}`] || props[`on${capitalize(event)}`]
if (!handler && event.indexOf('update:') === 0) {
event = hyphenate(event)
handler = props[`on${event}`] || props[`on${capitalize(event)}`]
}
if (handler) {
const res = callWithAsyncErrorHandling(
handler,