From e2dc96c7b95dfafe1e0a3d9e085631ddec93f472 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Mon, 28 Oct 2019 11:43:45 -0700 Subject: [PATCH] Fix runtime preventDefault / stopPropagation break. - The Blazor runtime doesn't support adding attributes prior to any sort of content frames being applied. This change ensures that `ComponentAttributes` (how preventDefault / stopPropagation are represented) are handled like other HTML attributes (applied first). - Updated existing tests and their baselines. aspnet/AspNetCoredotnet/aspnetcore-tooling#16611 \n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/1513cd2a5bf714c007fdc8e5e3ec25af530438d6 --- .../Components/ComponentRuntimeNodeWriter.cs | 4 +++ .../MarkupElementIntermediateNode.cs | 1 + .../ComponentCodeGenerationTestBase.cs | 4 +-- .../TestComponent.codegen.cs | 17 ++++++++--- .../TestComponent.ir.txt | 29 ++++++++++++------- .../TestComponent.mappings.txt | 21 +++++++++----- .../TestComponent.ir.txt | 4 ++- .../TestComponent.codegen.cs | 4 +-- .../TestComponent.codegen.cs | 24 ++++++++++----- .../TestComponent.ir.txt | 25 ++++++++++------ .../TestComponent.mappings.txt | 4 +-- .../TestComponent.codegen.cs | 3 +- .../TestComponent.ir.txt | 4 ++- 13 files changed, 96 insertions(+), 48 deletions(-) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentRuntimeNodeWriter.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentRuntimeNodeWriter.cs index 82fb75666f..b57552e5e6 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentRuntimeNodeWriter.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Components/ComponentRuntimeNodeWriter.cs @@ -191,6 +191,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Components { 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/Microsoft.AspNetCore.Razor.Language/src/Intermediate/MarkupElementIntermediateNode.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/MarkupElementIntermediateNode.cs index db29186789..cd7ddc756c 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/MarkupElementIntermediateNode.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Intermediate/MarkupElementIntermediateNode.cs @@ -19,6 +19,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate 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/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs index b7b77640cf..1fde6741b2 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/IntegrationTests/ComponentCodeGenerationTestBase.cs @@ -2905,7 +2905,7 @@ namespace Test // Act var generated = CompileToCSharp(@" @using Microsoft.AspNetCore.Components.Web -"); +"); // Assert AssertDocumentNodeMatchesBaseline(generated.CodeDocument); @@ -2921,7 +2921,7 @@ namespace Test // Act var generated = CompileToCSharp(@" @using Microsoft.AspNetCore.Components.Web - + @code { bool Foo { get; set; } }"); diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs index 1bdae075cb..64cf9089f1 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs @@ -27,10 +27,10 @@ using Microsoft.AspNetCore.Components.Web; #pragma warning disable 1998 protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder) { - __o = Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( + __o = Microsoft.AspNetCore.Components.EventCallback.Factory.Create(this, #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - true + () => Foo = false #line default #line hidden @@ -39,7 +39,7 @@ using Microsoft.AspNetCore.Components.Web; __o = Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - Foo + true #line default #line hidden @@ -48,7 +48,16 @@ using Microsoft.AspNetCore.Components.Web; __o = Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( #nullable restore #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" - false + Foo + +#line default +#line hidden +#nullable disable + ); + __o = Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck( +#nullable restore +#line 2 "x:\dir\subdir\Test\TestComponent.cshtml" + false #line default #line hidden diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt index de4bf6f53e..3d45ad10b8 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/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/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt index 9681e57134..cad9e04b78 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/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/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt index fd1d8c7ac6..e4b3f44b85 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentDesignTimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/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/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs index abde22376c..42db467644 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_Duplicates/TestComponent.codegen.cs @@ -21,8 +21,7 @@ using Microsoft.AspNetCore.Components.Web; 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 @@ using Microsoft.AspNetCore.Components.Web; #line hidden #nullable disable ); + __builder.AddAttribute(2, "@onclick:preventDefault", true); __builder.CloseElement(); } #pragma warning restore 1998 diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs index 2b163cbdf5..4a66d9e841 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.codegen.cs @@ -20,34 +20,44 @@ using Microsoft.AspNetCore.Components.Web; #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/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt index d6d453bd47..fd4127c304 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/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/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt index 4df5db3ef2..de4927d371 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation/TestComponent.mappings.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/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/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs index d00a9ee79c..e166732cc1 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.codegen.cs @@ -20,9 +20,10 @@ using Microsoft.AspNetCore.Components.Web; #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/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt b/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt index ce28568d1b..99262a0fb5 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/test/TestFiles/IntegrationTests/ComponentRuntimeCodeGenerationTest/EventHandler_PreventDefault_StopPropagation_Minimized/TestComponent.ir.txt +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/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