You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bUnit currently triggers DOM event handlers like this:
For bubbling events, e.g. @onclick events, 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 MissingEventHandlerException is 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 XX exception).
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:
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 td and tronclick event handlers?
Does Blazor only trigger the tronclick event 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.
The text was updated successfully, but these errors were encountered:
If the target element's event handler throws or had been disposed, then the exception will get thrown to the user.
If a bubbled event handlers throw, then those exception are passed to the user. If a bubbled events handlers have been disposed, the exception from the Blazor renderer is swallowed/ignored.
If the a bubbled event handler has been disposed, any parent bubbling events are skipped, even if they are still there.
Another reason to follow the plan mentioned above is that this will restore the functionality of from before the 1.2.49 release which effectively swallowed all exceptions in most cases. So this is the path of "least surprise" for the users.
Actually, bUnit pre 1.2.49 did trigger the top parent element event handler, even if a lower event handler was disposed. It seems, based on experimenting with Blazor Server, that it is actually able invoke all event handlers before they get disposed. I.e. this component sets all three properties to true when the button is clicked:
Currently I cannot come up with a way to do the same in bUnit. The best we can do is to ignore then missing event handler for the MiddleDivClicked event and continue with the TopDivClicked event handler.
bUnit currently triggers DOM event handlers like this:
@onclick
events, 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.MissingEventHandlerException
is thrown. For bubbling events, at least one Blazor event handler must be found in the DOM tree.There is no event handler associated with this event. EventId XX
exception).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:
The user triggers the event handler bound to the
button
element, which causes the DOM to be updated, such that thetd
elementsonclick
handler is removed.td
andtr
onclick
event handlers?tr
onclick
event handler that is still bound?My experiments up till now has been inconclusive, so hoping somebody, perhaps @SteveSandersonMS, can help clear things up.
The text was updated successfully, but these errors were encountered: