Skip to content

bUnit's HtmlParser should detect markup context to avoid surprising users #198

@egil

Description

@egil

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions