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

Static functions or arrow functions do not work on components without a class statement #2029

Open
AndresBarreto-code opened this issue Aug 28, 2023 · 0 comments
Labels
type:unverified bug A bug report that has not been verified

Comments

@AndresBarreto-code
Copy link

Marko Version: @5.25.16

Details

It seems we need to include a class {} statement if we want to use Event handling. I have created two components, both components use buttons elements with on-click method, however, one should include a class statement so the events run. I have created the following repo to reproduce it.

See:
https://github.com/AndresBarreto-code/marko-components

Expected Behavior

The following component does not work:

static function handleClick() {
  alert("Component 1 Clicked by static function!");
}
<button on-click(handleClick)>
  Click static function
</button>

But the following component does work:

class {}
static function handleClick() {
  alert("Component 1 Clicked by static function!");
}
<button on-click(handleClick)>
  Click static function
</button>

Actual Behavior

We expected both components to work. We expected to use Event handling without a class statement.

Your Environment

  • Chrome 115.0.5790.173, node v18.15.0.
  • Windows 11.

Steps to Reproduce

  1. Clone the repo linked: https://github.com/AndresBarreto-code/marko-components
  2. Run the repo.
@AndresBarreto-code AndresBarreto-code added the type:unverified bug A bug report that has not been verified label Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:unverified bug A bug report that has not been verified
Projects
None yet
Development

No branches or pull requests

1 participant