Browse Source
Note this does not support modifiers and is meant to be used for handling events proxying in higher-order-components.dev
Evan You
7 years ago
12 changed files with 178 additions and 23 deletions
@ -1,9 +1,11 @@ |
|||
/* @flow */ |
|||
|
|||
import on from './on' |
|||
import bind from './bind' |
|||
import { noop } from 'shared/util' |
|||
|
|||
export default { |
|||
on, |
|||
bind, |
|||
cloak: noop |
|||
} |
|||
|
@ -0,0 +1,10 @@ |
|||
/* @flow */ |
|||
|
|||
import { warn } from 'core/util/index' |
|||
|
|||
export default function on (el: ASTElement, dir: ASTDirective) { |
|||
if (process.env.NODE_ENV !== 'production' && dir.modifiers) { |
|||
warn(`v-on without argument does not support modifiers.`) |
|||
} |
|||
el.wrapListeners = (code: string) => `_g(${code},${dir.value})` |
|||
} |
@ -0,0 +1,22 @@ |
|||
/* @flow */ |
|||
|
|||
import { warn, extend, isPlainObject } from 'core/util/index' |
|||
|
|||
export function bindObjectListeners (data: any, value: any): VNodeData { |
|||
if (value) { |
|||
if (!isPlainObject(value)) { |
|||
process.env.NODE_ENV !== 'production' && warn( |
|||
'v-on without argument expects an Object value', |
|||
this |
|||
) |
|||
} else { |
|||
const on = data.on = data.on ? extend({}, data.on) : {} |
|||
for (const key in value) { |
|||
const existing = on[key] |
|||
const ours = value[key] |
|||
on[key] = existing ? [ours].concat(existing) : ours |
|||
} |
|||
} |
|||
} |
|||
return data |
|||
} |
Loading…
Reference in new issue