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

Misunderstanding or bug? #207

Closed
TheLazyLemur opened this issue Aug 1, 2024 · 1 comment
Closed

Misunderstanding or bug? #207

TheLazyLemur opened this issue Aug 1, 2024 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@TheLazyLemur
Copy link

TheLazyLemur commented Aug 1, 2024

Test case: https://codepen.io/cferdinandi/pen/GRmOyJJ

I have this code snippet where I am trying to pass two events into a component. However the second one that is used in the template throws a error:

let { signal, component, render } = reef;

customElements.define('count-up', class extends HTMLElement {
    constructor() {
        super();

        this.count = signal(0);

        let countUp = () => {
            this.count.value++;
        };

        let startDrag = () => {
            console.log('startDrag');
        };

        this.events = {
            countUp: countUp,
            startDrag: startDrag
        };

        component(this, this.template, { events: this.events });
    }

    template = () => {
        return `
            <div draggable="true" onmousedown="startDrag()">
                <button onclick="countUp()">Clicked ${this.count.value} times</button>
            </div>
            `;
    }

});
Uncaught ReferenceError: countUp is not defined
    at HTMLButtonElement.onclick ((index):1:1)
@cferdinandi
Copy link
Owner

Definitely a bug, seemingly the same one here: #200

Closing this issue only because it's a duplicate of an existing bug that already has some chat around it, but linking the two as related.

Thanks for filing this!

@cferdinandi cferdinandi added bug Something isn't working duplicate This issue or pull request already exists labels Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants