vue3-yuanma/packages/runtime-core/src/helpers/toHandlers.ts

19 lines
465 B
TypeScript
Raw Normal View History

import { toHandlerKey, isObject } from '@vue/shared'
2019-09-25 08:51:48 +08:00
import { warn } from '../warning'
/**
* For prefixing keys in v-on="obj" with "on"
* @private
*/
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) {
ret[toHandlerKey(key)] = obj[key]
2019-09-25 08:51:48 +08:00
}
return ret
}