Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt components that require $listeners to Vue 3 API #121

Open
1 task
rafaelcamargo opened this issue Jul 3, 2022 · 0 comments
Open
1 task

Adapt components that require $listeners to Vue 3 API #121

rafaelcamargo opened this issue Jul 3, 2022 · 0 comments
Labels
enhancement New feature or request vue3

Comments

@rafaelcamargo
Copy link
Member

Component's Name

<t-button>, <t-close-button>, <t-input>, <t-textarea>, <t-select>

Common pattern to be abstracted

The attribute $listeners was removed on Vue 3. Listeners were incorporated to the attribute $attrs. The components listed above should now being able to handle with this differentiation between Vue versions. One possible strategy would be handle this conditional in a separate service and use it in every component that requires $listeners:

// vue/services/vm/vm.js
const _public = {};

_public.getListeners = vm => vm.$listeners || {}

export default _public
// vue/services/vm/vm.js
const _public = {};

_public.getListeners = vm => vm.$listeners || {}

export default _public
// vue/components/button/button.js
import vmService from '@vue/services/vm/vm';

export const tButton = {
  name: 't-button',
  // ...
  methods: {
    getListeners(){
      return vmService.getListeners(this);
    }
  }
}
<!-- vue/components/button/button.html -->
<component :is="tagName" :class="classes" :type="buttonType" tabindex="0" v-on="getListeners()">
  <!-- ... -->
</component>

Requirements

  • Create vmService and apply it to the components that require $listeners

Properties

N/A

@rafaelcamargo rafaelcamargo added enhancement New feature or request vue3 labels Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vue3
Projects
None yet
Development

No branches or pull requests

1 participant