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

Parent ‘on load’ event triggering multiple times due to DOM re-renders or updates with child event handlers #586

Closed
restless opened this issue Oct 31, 2024 · 1 comment

Comments

@restless
Copy link

I'm not 100% sure if that's a bug but I believe is either unexpected or expected but not documented.

Simply put, when the page defined below is opened then the "on load" event is triggered 3 times. At the same time the "init" is executed only once (as expected). It can be validated in the devtools by checking the printed messages.

<html>
  <head>
    <script src="https://unpkg.com/[email protected]"></script>
  </head>
  <body>

    <div _="on load log 'on load'">
      On load
      <button _="on click log 'clicked'">Click me</button>
      <button _="on click log 'clicked 2'">Click me too</button>
    </div>

    <div _="init log 'init'">
      Init
      <button _="on click log 'clicked'">Click me</button>
    </div>

  </body>
</html>

So, is it expected or it's a bug?

@1cg
Copy link
Contributor

1cg commented Dec 17, 2024

yes, expected, the load event bubbles:

this.triggerEvent(target || elt, "load", {

@1cg 1cg closed this as completed Dec 17, 2024
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

No branches or pull requests

2 participants