fix(compiler-core/v-on): bail caching for member expression handlers on components
to preserve correct arity when it is passed down. fix #1541
This commit is contained in:
@@ -13,7 +13,7 @@ import { transformElement } from '../../src/transforms/transformElement'
|
||||
import { transformExpression } from '../../src/transforms/transformExpression'
|
||||
|
||||
function parseWithVOn(template: string, options: CompilerOptions = {}) {
|
||||
const ast = parse(template)
|
||||
const ast = parse(template, options)
|
||||
transform(ast, {
|
||||
nodeTransforms: [transformExpression, transformElement],
|
||||
directiveTransforms: {
|
||||
@@ -405,6 +405,15 @@ describe('compiler: transform v-on', () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('bail on component member expression handler', () => {
|
||||
const { root } = parseWithVOn(`<comp v-on:click="foo" />`, {
|
||||
prefixIdentifiers: true,
|
||||
cacheHandlers: true,
|
||||
isNativeTag: tag => tag === 'div'
|
||||
})
|
||||
expect(root.cached).toBe(0)
|
||||
})
|
||||
|
||||
test('inline function expression handler', () => {
|
||||
const { root, node } = parseWithVOn(`<div v-on:click="() => foo()" />`, {
|
||||
prefixIdentifiers: true,
|
||||
|
||||
Reference in New Issue
Block a user