-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Trigger OnCancel and OnClose event on dialog
- Loading branch information
1 parent
c37455b
commit 2afd487
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/bunit.web/EventDispatchExtensions/DialogEventDispatchExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using AngleSharp.Dom; | ||
|
||
#if NET8_0_OR_GREATER | ||
namespace Bunit; | ||
|
||
/// <summary> | ||
/// Dialog helper events. | ||
/// </summary> | ||
public static class DialogEventDispatchExtensions | ||
{ | ||
/// <summary> | ||
/// Raises the <c>@oncancel</c> event on <paramref name="element"/>, passing an empty (<see cref="EventArgs.Empty"/>). | ||
/// </summary> | ||
public static void Cancel(this IElement element) => _ = CancelAsync(element); | ||
|
||
/// <summary> | ||
/// Raises the <c>@oncancel</c> event on <paramref name="element"/>, passing an empty (<see cref="EventArgs.Empty"/>). | ||
/// </summary> | ||
public static Task CancelAsync(this IElement element) => element.TriggerEventAsync("oncancel", EventArgs.Empty); | ||
|
||
/// <summary> | ||
/// Raises the <c>@onclose</c> event on <paramref name="element"/>, passing an empty (<see cref="EventArgs.Empty"/>. | ||
/// </summary> | ||
public static void Close(this IElement element) => _ = CloseAsync(element); | ||
|
||
/// <summary> | ||
/// Raises the <c>@onclose</c> event on <paramref name="element"/>, passing an empty (<see cref="EventArgs.Empty"/>. | ||
/// </summary> | ||
public static Task CloseAsync(this IElement element) => element.TriggerEventAsync("onclose", EventArgs.Empty); | ||
} | ||
#endif |