feat: v-on with no argument

This commit is contained in:
Evan You
2019-09-24 20:51:48 -04:00
parent 0707fa5d21
commit 9b06e04e0f
6 changed files with 123 additions and 19 deletions

View File

@@ -0,0 +1,15 @@
import { isObject } from '@vue/shared'
import { warn } from '../warning'
// For prefixing keys in v-on="obj" with "on"
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[`on${key}`] = obj[key]
}
return ret
}