fix(v-on): refactor DOM event options modifer handling
fix #1567 Previously multiple `v-on` handlers with different event attach option modifers (`.once`, `.capture` and `.passive`) are generated as an array of objects in the form of `[{ handler, options }]` - however, this makes it pretty complex for `runtime-dom` to properly handle all possible value permutations, as each handler may need to be attached with different options. With this commit, they are now generated as event props with different keys - e.g. `v-on:click.capture` is now generated as a prop named `onClick.capture`. This allows them to be patched as separate props which makes the runtime handling much simpler.
This commit is contained in:
@@ -6,7 +6,9 @@ import {
|
||||
CompilerOptions,
|
||||
ErrorCodes,
|
||||
NodeTypes,
|
||||
VNodeCall
|
||||
VNodeCall,
|
||||
helperNameMap,
|
||||
CAPITALIZE
|
||||
} from '../../src'
|
||||
import { transformOn } from '../../src/transforms/vOn'
|
||||
import { transformElement } from '../../src/transforms/transformElement'
|
||||
@@ -73,7 +75,11 @@ describe('compiler: transform v-on', () => {
|
||||
{
|
||||
key: {
|
||||
type: NodeTypes.COMPOUND_EXPRESSION,
|
||||
children: [`"on" + (`, { content: `event` }, `)`]
|
||||
children: [
|
||||
`"on" + _${helperNameMap[CAPITALIZE]}(`,
|
||||
{ content: `event` },
|
||||
`)`
|
||||
]
|
||||
},
|
||||
value: {
|
||||
type: NodeTypes.SIMPLE_EXPRESSION,
|
||||
@@ -94,7 +100,11 @@ describe('compiler: transform v-on', () => {
|
||||
{
|
||||
key: {
|
||||
type: NodeTypes.COMPOUND_EXPRESSION,
|
||||
children: [`"on" + (`, { content: `_ctx.event` }, `)`]
|
||||
children: [
|
||||
`"on" + _${helperNameMap[CAPITALIZE]}(`,
|
||||
{ content: `_ctx.event` },
|
||||
`)`
|
||||
]
|
||||
},
|
||||
value: {
|
||||
type: NodeTypes.SIMPLE_EXPRESSION,
|
||||
@@ -116,7 +126,7 @@ describe('compiler: transform v-on', () => {
|
||||
key: {
|
||||
type: NodeTypes.COMPOUND_EXPRESSION,
|
||||
children: [
|
||||
`"on" + (`,
|
||||
`"on" + _${helperNameMap[CAPITALIZE]}(`,
|
||||
{ content: `_ctx.event` },
|
||||
`(`,
|
||||
{ content: `_ctx.foo` },
|
||||
|
||||
Reference in New Issue
Block a user