Skip to content

Commit 29cbd3d

Browse files
Copilotegil
andcommitted
Simplify FindFormById by removing GetElementById attempt
Co-authored-by: egil <[email protected]>
1 parent 36a5d18 commit 29cbd3d

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/bunit/EventDispatchExtensions/TriggerEventDispatchExtensions.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,9 @@ private static bool TryGetParentFormElementSpecialCase(
205205

206206
private static IHtmlFormElement? FindFormById(IElement element, string formId)
207207
{
208-
// First try the owner's GetElementById (most efficient if it works)
209-
var formByOwner = element.Owner?.GetElementById(formId) as IHtmlFormElement;
210-
if (formByOwner is not null)
211-
{
212-
return formByOwner;
213-
}
214-
215-
// If GetElementById didn't work (which can happen when AngleSharp's document ID indexing
216-
// doesn't include all elements), traverse up the DOM tree to find a common ancestor
217-
// and search its children. This handles cases where the button and form are siblings
218-
// or in different subtrees.
208+
// Traverse up the DOM tree to find a common ancestor and search its children
209+
// for the form with the matching ID. This handles cases where the button and
210+
// form are siblings or in different subtrees.
219211
var current = element.Parent as IElement;
220212
while (current is not null)
221213
{

0 commit comments

Comments
 (0)