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

fix(vue): emits events on runtime #566

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aesteves60
Copy link

@aesteves60 aesteves60 commented Dec 11, 2024

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally for affected output targets
  • Tests (npm test) were run locally and passed
  • Prettier (npm run prettier) was run locally and passed

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

  • Event do not emit in Vue on many common components.
// will never fire!
function myChange(e) {
  console.log("custom event change !") 
}

<MyComponent @myChange="myChange" />

Issue URL:
#382

What is the new behavior?

  • You can now handler on a custom event on a Vue component.
// will never fire!
function myChange(e) {
  console.log("custom event change !") 
}

<MyComponent @myChange="myChange" />

Does this introduce a breaking change?

  • Yes
  • No

Signed-off-by: Alexandre Esteves <[email protected]>
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation makes sense to me. Could we enhance the test cases for this?

* @see https://v3.vuejs.org/guide/component-custom-events.html#event-names
*/
emitProps.forEach((emitProp) => {
// @ts-expect-error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of expecting an error can we just define a new variable and cast it to the type we expect it to be?

Container.emits.push(UPDATE_VALUE_EVENT);
} else {
// @ts-expect-error
Container.emits = [UPDATE_VALUE_EVENT];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants