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
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user