Dunqing
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
32 additions and
1 deletions
packages/compiler-core/src/transforms/transformElement.ts
packages/compiler-sfc/__tests__/__snapshots__/compileTemplate.spec.ts.snap
packages/compiler-sfc/__tests__/compileTemplate.spec.ts
@ -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 ( )
} )