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
}

View File

@@ -41,6 +41,7 @@ export { applyDirectives } from './directives'
export { resolveComponent, resolveDirective } from './helpers/resolveAssets'
export { renderList } from './helpers/renderList'
export { toString } from './helpers/toString'
export { toHandlers } from './helpers/toHandlers'
export { capitalize } from '@vue/shared'
// Internal, for integration with runtime compiler