How to determine if events from CustomElements should bubble or not?

@deap82 the issue you described is how the web work. By default, event will be propagated through the DOM hierarchy unless getting stopped. Because of such, you need to distinguish where an event originates from through event .target. Doing so could be tedious and muddle your business logic with UI code, that’s why we have self binding behavior to help with that. So your template would look like this
image

And your demo with the self binding behavior giving the expected results: https://codesandbox.io/s/auts-nested-events-playground-dbx4y?fontsize=14&hidenavigation=1&theme=dark

You can read more about self binding behavior here https://aurelia.io/docs/binding/binding-behaviors#self

If the above answers your Q and helps solve your issue, could you help improve the doc so that it makes more sense/easier to find?

1 Like