UNPKG

597 BJavaScriptView Raw
1/* @flow */
2
3import { warn, extend, isPlainObject } from 'core/util/index'
4
5export function bindObjectListeners (data: any, value: any): VNodeData {
6 if (value) {
7 if (!isPlainObject(value)) {
8 process.env.NODE_ENV !== 'production' && warn(
9 'v-on without argument expects an Object value',
10 this
11 )
12 } else {
13 const on = data.on = data.on ? extend({}, data.on) : {}
14 for (const key in value) {
15 const existing = on[key]
16 const ours = value[key]
17 on[key] = existing ? [].concat(existing, ours) : ours
18 }
19 }
20 }
21 return data
22}