-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(v-on): support v-on object syntax with no arguments
Note this does not support modifiers and is meant to be used for handling events proxying in higher-order-components.
- Loading branch information
Showing
12 changed files
with
178 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
/* @flow */ | ||
|
||
import on from './on' | ||
import bind from './bind' | ||
import { noop } from 'shared/util' | ||
|
||
export default { | ||
on, | ||
bind, | ||
cloak: noop | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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})` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters