Skip to content

Support event handlers #42

@simonihmig

Description

@simonihmig

In the current form, it seems to me the codemod will skip over a lot of components, as many will have at least one event handler like click().

I believe it should be possible to transform these:

import Component from '@ember/component';

export default class FooComponent extends Component {
  tagName = 'button';
  click() {
    // do something
  }
}
{{@text}}

will be migrated to:

import Component from '@ember/component';
import { action } from '@ember/object';

export default class FooComponent extends Component {
  tagName = '';
  @action  
  handleClick() {
    // do something
  }
}
<button {{on "click" this.handleClick}}>
  {{@text}}
</button>

Or do I miss something that would make that more complicated?

Btw, this is assuming we have #3, don't know how useful this is for classic classes. 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions