Skip to content

Commit f1cb385

Browse files
committed
revert: Accidental change
1 parent fda9b5b commit f1cb385

File tree

1 file changed

+3
-40
lines changed

1 file changed

+3
-40
lines changed

src/bunit/EventDispatchExtensions/TriggerEventDispatchExtensions.cs

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -170,50 +170,13 @@ private static bool TryGetParentFormElementSpecialCase(
170170
return false;
171171
}
172172

173-
// Check if this is a submit element
174-
var isSubmitElement = element switch
173+
var form = element switch
175174
{
176-
IHtmlInputElement input => string.Equals(input.Type, "submit", StringComparison.OrdinalIgnoreCase),
177-
// Button defaults to type="submit" if not specified, so we check if it's NOT "button" or "reset"
178-
IHtmlButtonElement button => !string.Equals(button.Type, "button", StringComparison.OrdinalIgnoreCase)
179-
&& !string.Equals(button.Type, "reset", StringComparison.OrdinalIgnoreCase),
180-
_ => false
181-
};
182-
183-
if (!isSubmitElement)
184-
{
185-
return false;
186-
}
187-
188-
// Try to get the associated form, first via the Form property
189-
IHtmlFormElement? form = element switch
190-
{
191-
IHtmlInputElement { Form: not null } input => input.Form,
192-
IHtmlButtonElement { Form: not null } button => button.Form,
175+
IHtmlInputElement { Type: "submit", Form: not null } input => input.Form,
176+
IHtmlButtonElement { Type: "submit", Form: not null } button => button.Form,
193177
_ => null
194178
};
195179

196-
// If Form property is null but element has a form attribute, try to find the form by ID
197-
// This handles the case where a button/input is outside the form but associated via form attribute
198-
if (form is null && element.HasAttribute("form"))
199-
{
200-
var formId = element.GetAttribute("form");
201-
if (!string.IsNullOrEmpty(formId) && element.Owner is not null)
202-
{
203-
var foundElement = element.Owner.GetElementById(formId);
204-
// Unwrap in case it's wrapped
205-
form = (foundElement as IElement)?.Unwrap() as IHtmlFormElement;
206-
207-
// Debug
208-
System.Diagnostics.Debug.WriteLine($"Looking for form with ID '{formId}'. Found: {foundElement != null}, Is IHtmlFormElement: {form != null}");
209-
if (form != null)
210-
{
211-
var hasOnsubmit = form.TryGetEventId(Htmlizer.ToBlazorAttribute("onsubmit"), out var testEventId);
212-
System.Diagnostics.Debug.WriteLine($"Form has onsubmit event: {hasOnsubmit}, eventId: {testEventId}");
213-
}
214-
}
215-
}
216-
217180
return form is not null
218181
&& form.TryGetEventId(Htmlizer.ToBlazorAttribute("onsubmit"), out eventId);
219182
}

0 commit comments

Comments
 (0)