2020-10-20 05:15:53 +08:00
|
|
|
import { toHandlerKey, isObject } from '@vue/shared'
|
2019-09-25 08:51:48 +08:00
|
|
|
import { warn } from '../warning'
|
|
|
|
|
2020-05-01 05:04:35 +08:00
|
|
|
/**
|
|
|
|
* For prefixing keys in v-on="obj" with "on"
|
2020-06-11 02:57:21 +08:00
|
|
|
* @private
|
2020-05-01 05:04:35 +08:00
|
|
|
*/
|
2019-09-25 08:51:48 +08:00
|
|
|
export function toHandlers(obj: Record<string, any>): Record<string, any> {
|
|
|
|
const ret: Record<string, any> = {}
|
|
|
|
if (__DEV__ && !isObject(obj)) {
|
|
|
|
warn(`v-on with no argument expects an object value.`)
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
for (const key in obj) {
|
2020-10-20 05:15:53 +08:00
|
|
|
ret[toHandlerKey(key)] = obj[key]
|
2019-09-25 08:51:48 +08:00
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|