-
-
Notifications
You must be signed in to change notification settings - Fork 119
Ensure DOM event handlers are triggered like Blazor does it #518
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workinginvestigateThis issue require further investigation before closing.This issue require further investigation before closing.
Description
bUnit currently triggers DOM event handlers like this:
- For bubbling events, e.g.
@onclickevents, it starts with the trigger element and invokes the Blazor event handler (if present), and then walking up the DOM tree and finding all parent elements with a Blazor event handler attached matching the triggered event type, and triggers those as they are found. If a "stop event propagation" or disabled event is found, the bubbling stops. - For non-bubbling events, the Blazor event handler bound to the triggering element is invoked.
- In both cases, if no Blazor event handler is found, a
MissingEventHandlerExceptionis thrown. For bubbling events, at least one Blazor event handler must be found in the DOM tree. - If an Blazor event handler is triggered after it has been removed/disposed, i.e. because the owning component has been disposed/removed from the render tree, an exception is thrown by the Blazor Renderer (a
There is no event handler associated with this event. EventId XXexception).
This works well, and should align with how Blazor does it. However, it is unclear what Blazor does in the following scenario (inspired by #517):
Suppose we have (maybe multiple) components that render out something like the following markup:
<tr onclick="...">
<td onclick="...">
<button onclick="...">The user triggers the event handler bound to the button element, which causes the DOM to be updated, such that the td elements onclick handler is removed.
- Does Blazor still trigger the
tdandtronclickevent handlers? - Does Blazor only trigger the
tronclickevent handler that is still bound? - or does the bubbling stop, i.e. no more event handlers are triggered?
My experiments up till now has been inconclusive, so hoping somebody, perhaps @SteveSandersonMS, can help clear things up.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinginvestigateThis issue require further investigation before closing.This issue require further investigation before closing.