diff --git a/packages/vue/src/shared/connect.ts b/packages/vue/src/shared/connect.ts index 2d7e37c188b..6eb98c1b280 100644 --- a/packages/vue/src/shared/connect.ts +++ b/packages/vue/src/shared/connect.ts @@ -36,48 +36,27 @@ export function mapProps( }, input) return (target: T) => { - /* istanbul ignore else */ - if (isVue2) { - return defineComponent>({ - functional: true, + return observer( + defineComponent({ name: target.name ? `Connected${target.name}` : `ConnectedComponent`, - render(createElement, context) { + setup(props, { attrs, slots, listeners }: any) { const fieldRef = useField() - const { data } = context - const attrs = fieldRef.value - ? transform( - { ...data.attrs, ...data.props } as VueComponentProps, - fieldRef.value - ) - : { ...data.attrs, ...data.props } - return createElement(target, { ...data, attrs }, context.children) + return () => { + const newAttrs = fieldRef.value + ? transform({ ...attrs } as VueComponentProps, fieldRef.value) + : { ...attrs } + return h( + target, + { + attrs: newAttrs, + on: listeners, + }, + slots + ) + } }, }) - } else { - return observer( - defineComponent({ - name: target.name ? `Connected${target.name}` : `ConnectedComponent`, - setup(props, { attrs, slots }) { - const fieldRef = useField() - return () => { - const newAttrs = fieldRef.value - ? transform( - { ...attrs } as VueComponentProps, - fieldRef.value - ) - : { ...attrs } - return h( - target, - { - attrs: newAttrs, - }, - slots - ) - } - }, - }) - ) - } + ) } }