All files / runtime-core/src/helpers toHandlers.ts

100% Statements 10/10
100% Branches 3/3
100% Functions 1/1
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1984x 84x           84x 4x 4x 2x 2x   2x 4x   2x    
import { toHandlerKey, isObject } from '@vue/shared'
import { warn } from '../warning'
 
/**
 * For prefixing keys in v-on="obj" with "on"
 * @private
 */
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]
  }
  return ret
}