Skip to content

Conversation

@linkdotnet
Copy link
Collaborator

Add Find<TComponent, TElement> as a convenient way of having TElement returned.

So folks don't have to do:

var element = cut.Find("a") as IHtmlAnchorElement;

element.ShouldNotBeNull();
element.AssertWhatever();

Of course - if they are sure they could use:

var element = (IHtmAnchorElement)cut.Find("a");

And would get an exception. The new API would help here a bit better with a proper message inside the exception. That is also why I did not use Nodes.QuerySelector<TElement> internally, so that we can distinguish between:

  1. The css selector doesn't yield any element in the DOM
  2. There is an element, but the type is different

@linkdotnet linkdotnet requested a review from egil November 30, 2025 16:27
@linkdotnet linkdotnet force-pushed the find-by-specific-type branch from a0cea44 to 83d0a35 Compare November 30, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants