I have a simple Blazor project that contains a home page and a reference to Razor component library. The component contains a RenderFrament that is inserted in a <table> element, but the resulting HTML does not reflect this.
The project has a home page:
@page "/"<Grid Data="_data"><Rows Context="context"> @context.Name</Rows></Grid>@code { private List<Item> _data = null!; private class Item { public string Description { get; set; } = null!; public string Name { get; set; } = null!; public static Item Placeholder() => new() { Description = "foo", Name = "bar" }; } protected override void OnInitialized() { _data = [Item.Placeholder(), Item.Placeholder()]; }}And a reference to a Razor component library with the following files:Grid.razor
@typeparam T<table> @if (Data is not null) { @foreach (T row in Data) { @Rows(row) } }</table>Grid.razor.cs
using Microsoft.AspNetCore.Components;public partial class Grid<T> : ComponentBase{ [Parameter, EditorRequired] public List<T>? Data { get; set; } [Parameter, EditorRequired] public required RenderFragment<T> Rows { get; set; }}The resulting HTML is
<body> barbar<table></table></body>Why is barbar not contained in the <table> component?