Output
@@ -73,7 +69,5 @@
// This is so the descendants can detect and display whether they are
// newly-instantiated on any given render
public int UpdateCount { get; set; }
-
- public bool UseLooseKeys { get; set; }
}
}
diff --git a/src/Components/test/testassets/BasicTestApp/KeyCasesTreeNode.razor b/src/Components/test/testassets/BasicTestApp/KeyCasesTreeNode.razor
index c44d32528a..340e1046cd 100644
--- a/src/Components/test/testassets/BasicTestApp/KeyCasesTreeNode.razor
+++ b/src/Components/test/testassets/BasicTestApp/KeyCasesTreeNode.razor
@@ -1,4 +1,3 @@
-@using Microsoft.AspNetCore.Components.RenderTree
@Data.Label
[
@@ -17,9 +16,19 @@
@if (Data.Children?.Any() ?? false)
{
-
- @((RenderFragment)RenderKeyCasesTreeNodes)
-
+
@{
+ foreach (var child in Data.Children)
+ {
+ if (child.Key != null)
+ {
+
+ }
+ else
+ {
+
+ }
+ }
+ }
}
@@ -41,31 +50,4 @@
{
firstCreatedOnUpdateCount = RenderContext.UpdateCount;
}
-
- void RenderKeyCasesTreeNodes(RenderTreeBuilder builder)
- {
- // This is equivalent to:
- // @foreach (var child in Data.Children)
- // {
- // if (key != null)
- // {
- //
- // }
- // else
- // {
- //
- // }
- // }
- // TODO: Once the compiler supports @key:loose, eliminate this and just use regular Razor syntax
- foreach (var child in Data.Children)
- {
- builder.OpenComponent
(0);
- if (child.Key != null)
- {
- builder.SetKey(child.Key, looseKey: RenderContext.UseLooseKeys);
- }
- builder.AddAttribute(1, nameof(Data), child);
- builder.CloseComponent();
- }
- }
}