mirror of https://github.com/vuejs/core.git
fix(compilre-core): dynamic v-on and static v-on should be merged (#6747)
fix #6742
This commit is contained in:
parent
cae1aa82cc
commit
f9d43b99f8
|
@ -668,7 +668,17 @@ export function buildProps(
|
|||
// has built-in directive transform.
|
||||
const { props, needRuntime } = directiveTransform(prop, node, context)
|
||||
!ssr && props.forEach(analyzePatchFlag)
|
||||
properties.push(...props)
|
||||
if (isVOn && arg && !isStaticExp(arg)) {
|
||||
if (properties.length) {
|
||||
mergeArgs.push(
|
||||
createObjectExpression(dedupeProperties(properties), elementLoc)
|
||||
)
|
||||
properties = []
|
||||
}
|
||||
mergeArgs.push(createObjectExpression(props, elementLoc))
|
||||
} else {
|
||||
properties.push(...props)
|
||||
}
|
||||
if (needRuntime) {
|
||||
runtimeDirectives.push(prop)
|
||||
if (isSymbol(needRuntime)) {
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`dynamic v-on + static v-on should merged 1`] = `
|
||||
"import { toHandlerKey as _toHandlerKey, mergeProps as _mergeProps, openBlock as _openBlock, createElementBlock as _createElementBlock } from \\"vue\\"
|
||||
|
||||
export function render(_ctx, _cache) {
|
||||
return (_openBlock(), _createElementBlock(\\"input\\", _mergeProps({
|
||||
onBlur: _cache[0] || (_cache[0] = (...args) => (_ctx.onBlur && _ctx.onBlur(...args)))
|
||||
}, {
|
||||
[_toHandlerKey(_ctx.validateEvent)]: _cache[1] || (_cache[1] = (...args) => (_ctx.onValidateEvent && _ctx.onValidateEvent(...args)))
|
||||
}), null, 16 /* FULL_PROPS */))
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`should not hoist srcset URLs in SSR mode 1`] = `
|
||||
"import { resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode } from \\"vue\\"
|
||||
import { ssrRenderAttr as _ssrRenderAttr, ssrRenderComponent as _ssrRenderComponent } from \\"vue/server-renderer\\"
|
||||
|
|
|
@ -174,3 +174,12 @@ test('should not hoist srcset URLs in SSR mode', () => {
|
|||
})
|
||||
expect(code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
// #6742
|
||||
test('dynamic v-on + static v-on should merged', () => {
|
||||
const source = `<input @blur="onBlur" @[validateEvent]="onValidateEvent">`
|
||||
|
||||
const result = compile({ filename: 'example.vue', source })
|
||||
|
||||
expect(result.code).toMatchSnapshot()
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue