feat: v-on with no argument
This commit is contained in:
15
packages/runtime-core/src/helpers/toHandlers.ts
Normal file
15
packages/runtime-core/src/helpers/toHandlers.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user