bUnit
bUnit copied to clipboard
Allow components without ChildContent to be added to RenderTree
Users sometimes need to add mandatory components into the render tree that does not have a ChildContent parameter.
The RenderTree currently only allows adding components that has a ChildContent property, but that is an arbitrary limitation we can work around.
Now, if you call RenderTree.Add, the component is added as a child of the previous component.
However, I see no downside in allowing RenderFragments in general to be added to the render tree.
IFF a component with a ChildContent is added, then any other components or fragments will be added as children under that. If not, they are added at the root.
There are probably some edge cases I haven't thought about, so lets discuss first.
In general, I am on your side, the only open question for me is this:
Users sometimes need to add mandatory components into the render tree that does not have a ChildContent parameter.
This seems more related to 3rd party components, where creating stubs might be the better approach. Or do you have an example at hand?
It's a pattern I saw in some test code. I think the component being added was a popup content placeholder which was accessed via the services collection by child components.
And yes, more likely in scenarios that involves 3rd party components.