bUnit's HtmlParser uses AngleSharp's built in html parser to convert generated markup from a component or markup passed to MarkupMatches into a DOM tree. It's parse context is set to the <body> tag, which means that a string like <th>foo</th> results in a TextNode with the content foo, and not a Element.
This causes problems when users want to pass <th>foo</th> to MarkupMatches() or if they are testing a component which generates a <td> outside of a <table>.
In general, we cannot get around that users have to generate valid HTML5. But if the first element in rendered markup is one of the special elements that needs a specific context, then we can set that context for them, e.g. use table as the context for <th>foo</th>.
First reported in #197 by @brychart.
bUnit's HtmlParser uses AngleSharp's built in html parser to convert generated markup from a component or markup passed to
MarkupMatchesinto a DOM tree. It's parse context is set to the<body>tag, which means that a string like<th>foo</th>results in aTextNodewith the contentfoo, and not aElement.This causes problems when users want to pass
<th>foo</th>toMarkupMatches()or if they are testing a component which generates a<td>outside of a<table>.In general, we cannot get around that users have to generate valid HTML5. But if the first element in rendered markup is one of the special elements that needs a specific context, then we can set that context for them, e.g. use
tableas the context for<th>foo</th>.First reported in #197 by @brychart.