diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentRuntimeNodeWriter.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentRuntimeNodeWriter.cs index 82fb75666fa..b57552e5e6a 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentRuntimeNodeWriter.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Components/ComponentRuntimeNodeWriter.cs @@ -191,6 +191,10 @@ public override void WriteMarkupElement(CodeRenderingContext context, MarkupElem { context.RenderNode(attribute); } + else if (child is ComponentAttributeIntermediateNode componentAttribute) + { + context.RenderNode(componentAttribute); + } else if (child is SplatIntermediateNode splat) { context.RenderNode(splat); diff --git a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MarkupElementIntermediateNode.cs b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MarkupElementIntermediateNode.cs index db29186789b..cd7ddc756ca 100644 --- a/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MarkupElementIntermediateNode.cs +++ b/src/Razor/src/Microsoft.AspNetCore.Razor.Language/Intermediate/MarkupElementIntermediateNode.cs @@ -19,6 +19,7 @@ public sealed class MarkupElementIntermediateNode : IntermediateNode public IEnumerable Body => Children.Where(c => { return + c as ComponentAttributeIntermediateNode == null && c as HtmlAttributeIntermediateNode == null && c as SplatIntermediateNode == null && c as SetKeyIntermediateNode == null && diff --git a/src/Razor/test/RazorLanguage.Test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Razor/test/RazorLanguage.Test/IntegrationTests/ComponentCodeGenerationTestBase.cs index b7b77640cfa..1fde6741b2b 100644 --- a/src/Razor/test/RazorLanguage.Test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Razor/test/RazorLanguage.Test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -2905,7 +2905,7 @@ public void EventHandler_PreventDefault_StopPropagation_Minimized() // Act var generated = CompileToCSharp(@" @using Microsoft.AspNetCore.Components.Web -"); +"); // Assert AssertDocumentNodeMatchesBaseline(generated.CodeDocument); @@ -2921,7 +2921,7 @@ public void EventHandler_PreventDefault_StopPropagation() // Act var generated = CompileToCSharp(@" @using Microsoft.AspNetCore.Components.Web - + @code { bool Foo { get; set; } }"); diff --git a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs index 1bdae075cb2..64cf9089f11 100644 --- a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs +++ b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs @@ -27,10 +27,19 @@ private void __RazorDirectiveTokenHelpers__() { #pragma warning disable 1998 protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { + __o = Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + () => Foo = false + +#line default +#line hidden +#nullable disable + ); __o = Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - true + true #line default #line hidden @@ -39,7 +48,7 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin __o = Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - Foo + Foo #line default #line hidden @@ -48,7 +57,7 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin __o = Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - false + false #line default #line hidden diff --git a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt index de4bf6f53e1..3d45ad10b8b 100644 --- a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt +++ b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt @@ -17,17 +17,24 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree HtmlContent - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - MarkupElement - (44:1,0 [104] x:\dir\subdir\Test\TestComponent.cshtml) - input - ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes + MarkupElement - (44:1,0 [149] x:\dir\subdir\Test\TestComponent.cshtml) - button + HtmlContent - (176:1,132 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (176:1,132 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Click Me + HtmlAttribute - (62:1,18 [17] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + IntermediateToken - (62:1,18 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => Foo = false + IntermediateToken - - CSharp - ) + ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true - ComponentAttribute - (108:1,64 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - StopPropagation - AttributeStructure.DoubleQuotes + IntermediateToken - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true + ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - StopPropagation - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - (108:1,64 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo - ComponentAttribute - (139:1,95 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - StopPropagation - AttributeStructure.DoubleQuotes + IntermediateToken - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo + ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - StopPropagation - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - (139:1,95 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - false - HtmlContent - (148:1,104 [2] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (148:1,104 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - CSharpCode - (157:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (157:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n bool Foo { get; set; }\n + IntermediateToken - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - false + HtmlContent - (193:1,149 [2] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (193:1,149 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + CSharpCode - (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n bool Foo { get; set; }\n diff --git a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt index 9681e571344..cad9e04b780 100644 --- a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt +++ b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt @@ -3,26 +3,31 @@ Source Location: (1:0,1 [41] x:\dir\subdir\Test\TestComponent.cshtml) Generated Location: (320:12,0 [41] ) |using Microsoft.AspNetCore.Components.Web| -Source Location: (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (62:1,18 [17] x:\dir\subdir\Test\TestComponent.cshtml) +|() => Foo = false| +Generated Location: (1173:32,18 [17] ) +|() => Foo = false| + +Source Location: (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) |true| -Generated Location: (1158:32,32 [4] ) +Generated Location: (1500:41,62 [4] ) |true| -Source Location: (108:1,64 [3] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) |Foo| -Generated Location: (1474:41,64 [3] ) +Generated Location: (1846:50,94 [3] ) |Foo| -Source Location: (139:1,95 [5] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) |false| -Generated Location: (1820:50,95 [5] ) +Generated Location: (2222:59,125 [5] ) |false| -Source Location: (157:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) | bool Foo { get; set; } | -Generated Location: (2019:60,7 [30] ) +Generated Location: (2421:69,7 [30] ) | bool Foo { get; set; } | diff --git a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt index fd1d8c7ac6a..e4b3f44b85e 100644 --- a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt +++ b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt @@ -17,6 +17,8 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree HtmlContent - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (42:0,42 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n - MarkupElement - (44:1,0 [58] x:\dir\subdir\Test\TestComponent.cshtml) - input + MarkupElement - (44:1,0 [74] x:\dir\subdir\Test\TestComponent.cshtml) - button + HtmlContent - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Click Me ComponentAttribute - - onclick - PreventDefault - AttributeStructure.Minimized ComponentAttribute - - onclick - StopPropagation - AttributeStructure.Minimized diff --git a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs index abde22376c7..42db4676446 100644 --- a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs +++ b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs @@ -21,8 +21,7 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { __builder.OpenElement(0, "input"); - __builder.AddAttribute(1, "@onclick:preventDefault", true); - __builder.AddEventPreventDefaultAttribute(2, "onclick", + __builder.AddEventPreventDefaultAttribute(1, "onclick", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" true @@ -31,6 +30,7 @@ protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Renderin #line hidden #nullable disable ); + __builder.AddAttribute(2, "@onclick:preventDefault", true); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs index 2b163cbdf5b..4a66d9e841e 100644 --- a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs +++ b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs @@ -20,34 +20,44 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa #pragma warning disable 1998 protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __builder.OpenElement(0, "input"); - __builder.AddEventPreventDefaultAttribute(1, "onfocus", + __builder.OpenElement(0, "button"); + __builder.AddAttribute(1, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - true + () => Foo = false + +#line default +#line hidden +#nullable disable + )); + __builder.AddEventPreventDefaultAttribute(2, "onfocus", +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + true #line default #line hidden #nullable disable ); - __builder.AddEventStopPropagationAttribute(2, "onclick", + __builder.AddEventStopPropagationAttribute(3, "onclick", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - Foo + Foo #line default #line hidden #nullable disable ); - __builder.AddEventStopPropagationAttribute(3, "onfocus", + __builder.AddEventStopPropagationAttribute(4, "onfocus", #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - false + false #line default #line hidden #nullable disable ); + __builder.AddContent(5, "Click Me"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt index d6d453bd474..fd4127c304f 100644 --- a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt +++ b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt @@ -8,15 +8,22 @@ Document - UsingDirective - (1:0,1 [43] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components.Web ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree - MarkupElement - (44:1,0 [104] x:\dir\subdir\Test\TestComponent.cshtml) - input - ComponentAttribute - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes + MarkupElement - (44:1,0 [149] x:\dir\subdir\Test\TestComponent.cshtml) - button + HtmlContent - (176:1,132 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (176:1,132 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Click Me + HtmlAttribute - (62:1,18 [17] x:\dir\subdir\Test\TestComponent.cshtml) - onclick=" - " + CSharpExpressionAttributeValue - - + IntermediateToken - - CSharp - Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, + IntermediateToken - (62:1,18 [17] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - () => Foo = false + IntermediateToken - - CSharp - ) + ComponentAttribute - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - PreventDefault - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - (76:1,32 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true - ComponentAttribute - (108:1,64 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - StopPropagation - AttributeStructure.DoubleQuotes + IntermediateToken - (106:1,62 [4] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - true + ComponentAttribute - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - onclick - StopPropagation - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - (108:1,64 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo - ComponentAttribute - (139:1,95 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - StopPropagation - AttributeStructure.DoubleQuotes + IntermediateToken - (138:1,94 [3] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - Foo + ComponentAttribute - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - onfocus - StopPropagation - AttributeStructure.DoubleQuotes CSharpExpression - - IntermediateToken - (139:1,95 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - false - CSharpCode - (157:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (157:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n bool Foo { get; set; }\n + IntermediateToken - (169:1,125 [5] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - false + CSharpCode - (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - \n bool Foo { get; set; }\n diff --git a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt index 4df5db3ef22..de4927d3713 100644 --- a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt +++ b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt @@ -1,8 +1,8 @@ -Source Location: (157:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) +Source Location: (202:2,7 [30] x:\dir\subdir\Test\TestComponent.cshtml) | bool Foo { get; set; } | -Generated Location: (1720:55,7 [30] ) +Generated Location: (2205:65,7 [30] ) | bool Foo { get; set; } | diff --git a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs index d00a9ee79c6..e166732cc1e 100644 --- a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs +++ b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs @@ -20,9 +20,10 @@ public partial class TestComponent : Microsoft.AspNetCore.Components.ComponentBa #pragma warning disable 1998 protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __builder.OpenElement(0, "input"); + __builder.OpenElement(0, "button"); __builder.AddEventPreventDefaultAttribute(1, "onclick", true); __builder.AddEventStopPropagationAttribute(2, "onclick", true); + __builder.AddContent(3, "Click Me"); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt index ce28568d1b6..99262a0fb5c 100644 --- a/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt +++ b/src/Razor/test/RazorLanguage.Test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt @@ -8,6 +8,8 @@ Document - UsingDirective - (1:0,1 [43] x:\dir\subdir\Test\TestComponent.cshtml) - Microsoft.AspNetCore.Components.Web ClassDeclaration - - public partial - TestComponent - Microsoft.AspNetCore.Components.ComponentBase - MethodDeclaration - - protected override - void - BuildRenderTree - MarkupElement - (44:1,0 [58] x:\dir\subdir\Test\TestComponent.cshtml) - input + MarkupElement - (44:1,0 [74] x:\dir\subdir\Test\TestComponent.cshtml) - button + HtmlContent - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) + IntermediateToken - (101:1,57 [8] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Click Me ComponentAttribute - - onclick - PreventDefault - AttributeStructure.Minimized ComponentAttribute - - onclick - StopPropagation - AttributeStructure.Minimized