diff --git a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorExtensionInitializer.cs b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorExtensionInitializer.cs index 92ed7531bd..55ca4908a8 100644 --- a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorExtensionInitializer.cs +++ b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/BlazorExtensionInitializer.cs @@ -79,9 +79,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor builder.Features.Add(new EventHandlerLoweringPass()); builder.Features.Add(new RefLoweringPass()); builder.Features.Add(new BindLoweringPass()); - - // Temporarily disabled for 0.5.1 - // builder.Features.Add(new HtmlBlockPass()); + builder.Features.Add(new HtmlBlockPass()); builder.Features.Add(new ComponentTagHelperDescriptorProvider()); builder.Features.Add(new BindTagHelperDescriptorProvider()); diff --git a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/ComponentDocumentRewritePass.cs b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/ComponentDocumentRewritePass.cs index 6eb67919cd..1d35f15232 100644 --- a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/ComponentDocumentRewritePass.cs +++ b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/ComponentDocumentRewritePass.cs @@ -414,6 +414,13 @@ namespace Microsoft.AspNetCore.Blazor.Razor throw new InvalidOperationException("You need to call Push first."); } + // This will decode any HTML entities into their textual equivalent. + // + // This is OK because an HtmlContent node is used with document.createTextNode + // in the DOM, which can accept content that has decoded entities. + // + // In the event that we merge HtmlContent into an HtmlBlock, we need to + // re-encode the entites. That's done in the HtmlBlock pass. var tokens = _textSource.Tokenize(HtmlEntityService.Resolver); return tokens; } diff --git a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/HtmlBlockPass.cs b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/HtmlBlockPass.cs index 7013888059..a7dd2bf318 100644 --- a/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/HtmlBlockPass.cs +++ b/src/Microsoft.AspNetCore.Blazor.Razor.Extensions/HtmlBlockPass.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using AngleSharp.Html; using Microsoft.AspNetCore.Razor.Language; using Microsoft.AspNetCore.Razor.Language.Intermediate; @@ -166,11 +167,15 @@ namespace Microsoft.AspNetCore.Blazor.Razor IntermediateNodeWalker, IExtensionIntermediateNodeVisitor { + private readonly StringBuilder _encodingBuilder; + private readonly List _trees; public RewriteVisitor(List trees) { _trees = trees; + + _encodingBuilder = new StringBuilder(); } public StringBuilder Builder { get; } = new StringBuilder(); @@ -251,19 +256,28 @@ namespace Microsoft.AspNetCore.Blazor.Razor public override void VisitHtmlAttributeValue(HtmlAttributeValueIntermediateNode node) { - // Visit Children - base.VisitDefault(node); + Builder.Append(Encode(node.Children)); } public override void VisitHtml(HtmlContentIntermediateNode node) { - // Visit Children - base.VisitDefault(node); + Builder.Append(Encode(node.Children)); } - public override void VisitToken(IntermediateToken node) + private string Encode(IntermediateNodeCollection nodes) { - Builder.Append(node.Content); + // We need to HTML encode text content. We would have decoded HTML entities + // earlier when we parsed the text into a tree, but since we're folding + // this node into a block of pre-encoded HTML we need to be sure to + // re-encode. + _encodingBuilder.Clear(); + + for (var i = 0; i < nodes.Count; i++) + { + _encodingBuilder.Append(((IntermediateToken)nodes[i]).Content); + } + + return HtmlMarkupFormatter.Instance.Text(_encodingBuilder.ToString()); } } } diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/ComponentRenderingRazorIntegrationTest.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/ComponentRenderingRazorIntegrationTest.cs index 72cb7f574b..76b4b811ab 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/ComponentRenderingRazorIntegrationTest.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/ComponentRenderingRazorIntegrationTest.cs @@ -472,5 +472,21 @@ namespace Test frame => AssertFrame.Attribute(frame, "onmouseover", 1), frame => AssertFrame.Attribute(frame, "style", "background: #FFFFFF;", 2)); } + + // Text nodes decode HTML entities + [Fact] + public void Render_Component_HtmlEncoded() + { + // Arrange + var component = CompileToComponent(@"<span>Hi</span>"); + + // Act + var frames = GetRenderTree(component); + + // Assert + Assert.Collection( + frames, + frame => AssertFrame.Text(frame, "Hi")); + } } } diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/RuntimeCodeGenerationTest.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/RuntimeCodeGenerationTest.cs index f4f3ab9ef2..0afc2a7aca 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/RuntimeCodeGenerationTest.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/RuntimeCodeGenerationTest.cs @@ -1256,7 +1256,6 @@ namespace Test [Fact] // We don't process - we just skip them public void Component_WithDocType() { - GenerateBaselines = true; // Arrange // Act diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.codegen.cs index f05179d564..bec2a58f8b 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.codegen.cs @@ -19,10 +19,7 @@ namespace Test builder.AddAttribute(1, "MyAttr", "abc"); builder.AddAttribute(2, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => { builder2.AddContent(3, "Some text"); - builder2.OpenElement(4, "some-child"); - builder2.AddAttribute(5, "a", "1"); - builder2.AddContent(6, "Nested text"); - builder2.CloseElement(); + builder2.AddMarkupContent(4, "Nested text"); } )); builder.CloseComponent(); diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.ir.txt index bb2aa71df1..ef778dd366 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithChildContent/TestComponent.ir.txt @@ -13,12 +13,7 @@ Document - ComponentExtensionNode - (31:1,0 [91] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent HtmlContent - (57:1,26 [9] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (57:1,26 [9] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Some text - HtmlElement - (66:1,35 [42] x:\dir\subdir\Test\TestComponent.cshtml) - some-child - HtmlAttribute - - - - HtmlAttributeValue - - - IntermediateToken - - Html - 1 - HtmlContent - (84:1,53 [11] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (84:1,53 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Nested text + HtmlBlock - - Nested text ComponentAttributeExtensionNode - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - MyAttr - MyAttr HtmlContent - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (52:1,21 [3] x:\dir\subdir\Test\TestComponent.cshtml) - Html - abc diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.codegen.cs index 447f889959..a0676fe9c5 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.codegen.cs @@ -17,9 +17,7 @@ namespace Test base.BuildRenderTree(builder); builder.OpenComponent(0); builder.AddAttribute(1, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => { - builder2.OpenElement(2, "child"); - builder2.AddContent(3, "hello"); - builder2.CloseElement(); + builder2.AddMarkupContent(2, "hello"); } )); builder.CloseComponent(); diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.ir.txt index 92b0a33433..a232d19fb4 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/ChildComponent_WithElementOnlyChildContent/TestComponent.ir.txt @@ -11,6 +11,4 @@ Document - CSharpCode - IntermediateToken - - CSharp - base.BuildRenderTree(builder); ComponentExtensionNode - (31:1,0 [47] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent - HtmlElement - (44:1,13 [20] x:\dir\subdir\Test\TestComponent.cshtml) - child - HtmlContent - (51:1,20 [5] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (51:1,20 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - hello + HtmlBlock - - hello diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs index 3c9446c163..83cfd5344e 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithDocType/TestComponent.codegen.cs @@ -15,9 +15,7 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder) { base.BuildRenderTree(builder); - builder.OpenElement(0, "div"); - builder.AddContent(1, "\n"); - builder.CloseElement(); + builder.AddMarkupContent(0, "
\n
"); } #pragma warning restore 1998 } diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt index f0dd1aff52..4fdad553e2 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithDocType/TestComponent.ir.txt @@ -10,6 +10,4 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree CSharpCode - IntermediateToken - - CSharp - base.BuildRenderTree(builder); - HtmlElement - (17:1,0 [13] x:\dir\subdir\Test\TestComponent.cshtml) - div - HtmlContent - (22:1,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (22:1,5 [2] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n + HtmlBlock - -
\n
diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs index 96e1113792..072760b8c0 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.codegen.cs @@ -19,13 +19,11 @@ namespace Test builder.AddAttribute(1, "SomeProp", "val"); builder.AddAttribute(2, "ChildContent", (Microsoft.AspNetCore.Blazor.RenderFragment)((builder2) => { builder2.AddContent(3, "\n Some "); - builder2.OpenElement(4, "el"); - builder2.AddContent(5, "further"); - builder2.CloseElement(); - builder2.AddContent(6, " content\n"); + builder2.AddMarkupContent(4, "further"); + builder2.AddContent(5, " content\n"); } )); - builder.AddComponentReferenceCapture(7, (__value) => { + builder.AddComponentReferenceCapture(6, (__value) => { #line 2 "x:\dir\subdir\Test\TestComponent.cshtml" myInstance = (Test.MyComponent)__value; diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt index 56e7dd13bf..f35669e7a8 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.ir.txt @@ -13,9 +13,7 @@ Document - ComponentExtensionNode - (31:1,0 [96] x:\dir\subdir\Test\TestComponent.cshtml) - MyComponent - Test.MyComponent HtmlContent - (76:1,45 [11] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (76:1,45 [11] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n Some - HtmlElement - (87:2,9 [16] x:\dir\subdir\Test\TestComponent.cshtml) - el - HtmlContent - (91:2,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (91:2,13 [7] x:\dir\subdir\Test\TestComponent.cshtml) - Html - further + HtmlBlock - - further HtmlContent - (103:2,25 [10] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (103:2,25 [10] x:\dir\subdir\Test\TestComponent.cshtml) - Html - content\n RefExtensionNode - (49:1,18 [10] x:\dir\subdir\Test\TestComponent.cshtml) - myInstance - Test.MyComponent diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt index 205321b96c..5928e2d3b7 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Component_WithRef_WithChildContent/TestComponent.mappings.txt @@ -1,13 +1,13 @@ Source Location: (49:1,18 [10] x:\dir\subdir\Test\TestComponent.cshtml) |myInstance| -Generated Location: (1251:30,18 [10] ) +Generated Location: (1176:28,18 [10] ) |myInstance| Source Location: (143:5,12 [44] x:\dir\subdir\Test\TestComponent.cshtml) | private Test.MyComponent myInstance; | -Generated Location: (1505:40,12 [44] ) +Generated Location: (1430:38,12 [44] ) | private Test.MyComponent myInstance; | diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs index 96cd751df4..a6f8fc8235 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs @@ -17,9 +17,7 @@ namespace Test base.BuildRenderTree(builder); builder.AddContent(0, "My value"); builder.AddContent(1, "\n\n"); - builder.OpenElement(2, "h1"); - builder.AddContent(3, "Hello"); - builder.CloseElement(); + builder.AddMarkupContent(2, "

Hello

"); } #pragma warning restore 1998 } diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt index cd7b1a3b5d..77ccff6f9c 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt @@ -14,6 +14,4 @@ Document - IntermediateToken - (2:0,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) - CSharp - "My value" HtmlContent - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (13:0,13 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n - HtmlElement - (17:2,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 - HtmlContent - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlBlock - -

Hello

diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs index 02aa50e7f1..64d828bb4a 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.codegen.cs @@ -18,9 +18,7 @@ namespace Test builder.OpenComponent(0); builder.CloseComponent(); builder.AddContent(1, "\n\n"); - builder.OpenElement(2, "h1"); - builder.AddContent(3, "Hello"); - builder.CloseElement(); + builder.AddMarkupContent(2, "

Hello

"); } #pragma warning restore 1998 } diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt index a9a56bf975..a1d8d8b762 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithComponent/TestComponent.ir.txt @@ -13,6 +13,4 @@ Document - ComponentExtensionNode - (36:2,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent - Test.SomeOtherComponent HtmlContent - (58:2,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (58:2,22 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n - HtmlElement - (62:4,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 - HtmlContent - (66:4,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (66:4,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlBlock - -

Hello

diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs index 2b0c5b1f1b..3d1bc7f18b 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.codegen.cs @@ -15,9 +15,7 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder) { base.BuildRenderTree(builder); - builder.OpenElement(0, "h1"); - builder.AddContent(1, "Hello"); - builder.CloseElement(); + builder.AddMarkupContent(0, "

Hello

"); } #pragma warning restore 1998 } diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.ir.txt index ab555f741d..79e8e15da1 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/LeadingWhiteSpace_WithDirective/TestComponent.ir.txt @@ -10,6 +10,4 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree CSharpCode - IntermediateToken - - CSharp - base.BuildRenderTree(builder); - HtmlElement - (17:2,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 - HtmlContent - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (21:2,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlBlock - -

Hello

diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_772/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_772/TestComponent.codegen.cs index e84940c3b4..7d5094f269 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_772/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_772/TestComponent.codegen.cs @@ -16,12 +16,10 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder) { base.BuildRenderTree(builder); - builder.OpenElement(0, "h1"); - builder.AddContent(1, "Hello, world!"); - builder.CloseElement(); - builder.AddContent(2, "\n\nWelcome to your new app.\n\n"); - builder.OpenComponent(3); - builder.AddAttribute(4, "Title", ""); + builder.AddMarkupContent(0, "

Hello, world!

"); + builder.AddContent(1, "\n\nWelcome to your new app.\n\n"); + builder.OpenComponent(2); + builder.AddAttribute(3, "Title", ""); builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_772/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_772/TestComponent.ir.txt index 254965721c..238d257383 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_772/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_772/TestComponent.ir.txt @@ -11,9 +11,7 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree CSharpCode - IntermediateToken - - CSharp - base.BuildRenderTree(builder); - HtmlElement - (44:3,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - h1 - HtmlContent - (48:3,4 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (48:3,4 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello, world! + HtmlBlock - -

Hello, world!

HtmlContent - (66:3,22 [32] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (66:3,22 [32] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\nWelcome to your new app.\n\n ComponentExtensionNode - (98:7,0 [23] x:\dir\subdir\Test\TestComponent.cshtml) - SurveyPrompt - Test.SurveyPrompt diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_773/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_773/TestComponent.codegen.cs index 6a9b4db856..336eb6e0ec 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_773/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_773/TestComponent.codegen.cs @@ -16,12 +16,10 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder) { base.BuildRenderTree(builder); - builder.OpenElement(0, "h1"); - builder.AddContent(1, "Hello, world!"); - builder.CloseElement(); - builder.AddContent(2, "\n\nWelcome to your new app.\n\n"); - builder.OpenComponent(3); - builder.AddAttribute(4, "Title", "
Test!
"); + builder.AddMarkupContent(0, "

Hello, world!

"); + builder.AddContent(1, "\n\nWelcome to your new app.\n\n"); + builder.OpenComponent(2); + builder.AddAttribute(3, "Title", "
Test!
"); builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_773/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_773/TestComponent.ir.txt index 3cf7b01158..161232aae6 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_773/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/Regression_773/TestComponent.ir.txt @@ -11,9 +11,7 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree CSharpCode - IntermediateToken - - CSharp - base.BuildRenderTree(builder); - HtmlElement - (44:3,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - h1 - HtmlContent - (48:3,4 [13] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (48:3,4 [13] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello, world! + HtmlBlock - -

Hello, world!

HtmlContent - (66:3,22 [32] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (66:3,22 [32] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\nWelcome to your new app.\n\n ComponentExtensionNode - (98:7,0 [41] x:\dir\subdir\Test\TestComponent.cshtml) - SurveyPrompt - Test.SurveyPrompt diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs index b9e370ab5b..c561840bfd 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.codegen.cs @@ -15,11 +15,9 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder) { base.BuildRenderTree(builder); - builder.OpenElement(0, "h1"); - builder.AddContent(1, "Hello"); - builder.CloseElement(); - builder.AddContent(2, "\n\n"); - builder.AddContent(3, "My value"); + builder.AddMarkupContent(0, "

Hello

"); + builder.AddContent(1, "\n\n"); + builder.AddContent(2, "My value"); } #pragma warning restore 1998 } diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt index f2dad13635..580bbd8848 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithCSharpExpression/TestComponent.ir.txt @@ -10,9 +10,7 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree CSharpCode - IntermediateToken - - CSharp - base.BuildRenderTree(builder); - HtmlElement - (0:0,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 - HtmlContent - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlBlock - -

Hello

HtmlContent - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (14:0,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n CSharpExpression - (20:2,2 [10] x:\dir\subdir\Test\TestComponent.cshtml) diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs index ec5891600f..7cea719d6a 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.codegen.cs @@ -15,11 +15,9 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder) { base.BuildRenderTree(builder); - builder.OpenElement(0, "h1"); - builder.AddContent(1, "Hello"); - builder.CloseElement(); - builder.AddContent(2, "\n\n"); - builder.OpenComponent(3); + builder.AddMarkupContent(0, "

Hello

"); + builder.AddContent(1, "\n\n"); + builder.OpenComponent(2); builder.CloseComponent(); } #pragma warning restore 1998 diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.ir.txt index db06a72441..ccd7057150 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithComponent/TestComponent.ir.txt @@ -10,9 +10,7 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree CSharpCode - IntermediateToken - - CSharp - base.BuildRenderTree(builder); - HtmlElement - (31:1,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 - HtmlContent - (35:1,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (35:1,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlBlock - -

Hello

HtmlContent - (45:1,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) IntermediateToken - (45:1,14 [4] x:\dir\subdir\Test\TestComponent.cshtml) - Html - \n\n ComponentExtensionNode - (49:3,0 [22] x:\dir\subdir\Test\TestComponent.cshtml) - SomeOtherComponent - Test.SomeOtherComponent diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs index a85626313f..4f1afd7461 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.codegen.cs @@ -16,9 +16,7 @@ namespace Test protected override void BuildRenderTree(Microsoft.AspNetCore.Blazor.RenderTree.RenderTreeBuilder builder) { base.BuildRenderTree(builder); - builder.OpenElement(0, "h1"); - builder.AddContent(1, "Hello"); - builder.CloseElement(); + builder.AddMarkupContent(0, "

Hello

"); } #pragma warning restore 1998 } diff --git a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.ir.txt b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.ir.txt index 1435b21d2b..912c6e6252 100644 --- a/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.ir.txt +++ b/test/Microsoft.AspNetCore.Blazor.Build.Test/TestFiles/RuntimeCodeGenerationTest/TrailingWhiteSpace_WithDirective/TestComponent.ir.txt @@ -11,6 +11,4 @@ Document - MethodDeclaration - - protected override - void - BuildRenderTree CSharpCode - IntermediateToken - - CSharp - base.BuildRenderTree(builder); - HtmlElement - (0:0,0 [14] x:\dir\subdir\Test\TestComponent.cshtml) - h1 - HtmlContent - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - IntermediateToken - (4:0,4 [5] x:\dir\subdir\Test\TestComponent.cshtml) - Html - Hello + HtmlBlock - -

Hello

diff --git a/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/ComponentRenderingTest.cs b/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/ComponentRenderingTest.cs index e12703da7c..c9ee86fb55 100644 --- a/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/ComponentRenderingTest.cs +++ b/test/Microsoft.AspNetCore.Blazor.E2ETest/Tests/ComponentRenderingTest.cs @@ -156,6 +156,53 @@ namespace Microsoft.AspNetCore.Blazor.E2ETest.Tests Assert.Equal("somevalue", styledElement.GetAttribute("customattribute")); } + // Verifies we can render HTML content as a single block + [Fact] + public void CanRenderChildContent_StaticHtmlBlock() + { + var appElement = MountTestComponent(); + Assert.Equal("

Some-Static-Text

", + appElement.FindElement(By.Id("foo")).GetAttribute("innerHTML")); + } + + // Verifies we can rewite more complex HTML content into blocks + [Fact] + public void CanRenderChildContent_MixedHtmlBlock() + { + var appElement = MountTestComponent(); + + var one = appElement.FindElement(By.Id("one")); + Assert.Equal("

Some-Static-Text

", one.GetAttribute("innerHTML")); + + var two = appElement.FindElement(By.Id("two")); + Assert.Equal("More-Static-Text", two.GetAttribute("innerHTML")); + + var three = appElement.FindElement(By.Id("three")); + Assert.Equal("Some-Dynamic-Text", three.GetAttribute("innerHTML")); + + var four = appElement.FindElement(By.Id("four")); + Assert.Equal("But this is static", four.GetAttribute("innerHTML")); + } + + // Verifies we can rewrite HTML blocks with encoded HTML + [Fact] + public void CanRenderChildContent_EncodedHtmlInBlock() + { + var appElement = MountTestComponent(); + + var one = appElement.FindElement(By.Id("one")); + Assert.Equal("

Some-Static-Text

", one.GetAttribute("innerHTML")); + + var two = appElement.FindElement(By.Id("two")); + Assert.Equal("<span>More-Static-Text</span>", two.GetAttribute("innerHTML")); + + var three = appElement.FindElement(By.Id("three")); + Assert.Equal("Some-Dynamic-Text", three.GetAttribute("innerHTML")); + + var four = appElement.FindElement(By.Id("four")); + Assert.Equal("But this is static", four.GetAttribute("innerHTML")); + } + [Fact] public void CanTriggerEventsOnChildComponents() { diff --git a/test/Microsoft.AspNetCore.Blazor.Razor.Extensions.Test/HtmlBlockPassTest.cs b/test/Microsoft.AspNetCore.Blazor.Razor.Extensions.Test/HtmlBlockPassTest.cs index 6de6e87a7c..34df7f97fc 100644 --- a/test/Microsoft.AspNetCore.Blazor.Razor.Extensions.Test/HtmlBlockPassTest.cs +++ b/test/Microsoft.AspNetCore.Blazor.Razor.Extensions.Test/HtmlBlockPassTest.cs @@ -22,7 +22,11 @@ namespace Microsoft.AspNetCore.Blazor.Razor b => { BlazorExtensionInitializer.Register(b); - b.Features.Remove(b.Features.OfType().Single()); + + if (b.Features.OfType().Any()) + { + b.Features.Remove(b.Features.OfType().Single()); + } }).Engine; Pass.Engine = Engine; @@ -32,7 +36,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor private HtmlBlockPass Pass { get; } - [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + [Fact] public void Execute_RewritesHtml_Basic() { // Arrange @@ -60,7 +64,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor Assert.Equal(expected, block.Content, ignoreLineEndingDifferences: true); } - [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + [Fact] public void Execute_RewritesHtml_CSharpInAttributes() { // Arrange @@ -83,7 +87,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor Assert.Equal(expected, block.Content, ignoreLineEndingDifferences: true); } - [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + [Fact] public void Execute_RewritesHtml_CSharpInBody() { // Arrange @@ -108,7 +112,31 @@ namespace Microsoft.AspNetCore.Blazor.Razor Assert.Equal(expected, block.Content, ignoreLineEndingDifferences: true); } - [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + [Fact] + public void Execute_RewritesHtml_EncodesHtmlEntities() + { + // Arrange + var document = CreateDocument(@" +
+ <span>Hi</span> +
"); + + var expected = NormalizeContent(@" +
+ <span>Hi</span> +
"); + + var documentNode = Lower(document); + + // Act + Pass.Execute(document, documentNode); + + // Assert + var block = documentNode.FindDescendantNodes().Single(); + Assert.Equal(expected, block.Content, ignoreLineEndingDifferences: true); + } + + [Fact] public void Execute_RewritesHtml_EmptyNonvoid() { // Arrange @@ -126,7 +154,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor Assert.Equal(expected, block.Content, ignoreLineEndingDifferences: true); } - [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + [Fact] public void Execute_RewritesHtml_Void() { // Arrange @@ -144,7 +172,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor Assert.Equal(expected, block.Content, ignoreLineEndingDifferences: true); } - [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + [Fact] public void Execute_CannotRewriteHtml_CSharpInCode() { // Arrange @@ -167,7 +195,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor Assert.Empty(documentNode.FindDescendantNodes()); } - [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + [Fact] public void Execute_CannotRewriteHtml_Script() { // Arrange @@ -191,7 +219,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor } // The unclosed tag will have errors, so we won't rewrite it or its parent. - [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + [Fact] public void Execute_CannotRewriteHtml_Errors() { // Arrange @@ -209,7 +237,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor Assert.Empty(documentNode.FindDescendantNodes()); } - [Fact(Skip = "Temporarily disable compiling markup frames in 0.5.1")] + [Fact] public void Execute_RewritesHtml_MismatchedClosingTag() { // Arrange diff --git a/test/testapps/BasicTestApp/HtmlBlockChildContent.cshtml b/test/testapps/BasicTestApp/HtmlBlockChildContent.cshtml new file mode 100644 index 0000000000..411bf362f8 --- /dev/null +++ b/test/testapps/BasicTestApp/HtmlBlockChildContent.cshtml @@ -0,0 +1 @@ +

Some-Static-Text

\ No newline at end of file diff --git a/test/testapps/BasicTestApp/HtmlEncodedChildContent.cshtml b/test/testapps/BasicTestApp/HtmlEncodedChildContent.cshtml new file mode 100644 index 0000000000..e621b8589c --- /dev/null +++ b/test/testapps/BasicTestApp/HtmlEncodedChildContent.cshtml @@ -0,0 +1,7 @@ +
+ +

Some-Static-Text

+
<span>More-Static-Text</span>
+
@("Some-Dynamic-Text")But this is static
+
+
\ No newline at end of file diff --git a/test/testapps/BasicTestApp/HtmlMixedChildContent.cshtml b/test/testapps/BasicTestApp/HtmlMixedChildContent.cshtml new file mode 100644 index 0000000000..97808e2888 --- /dev/null +++ b/test/testapps/BasicTestApp/HtmlMixedChildContent.cshtml @@ -0,0 +1,7 @@ +
+ +

Some-Static-Text

+
More-Static-Text
+
@("Some-Dynamic-Text")But this is static
+
+
\ No newline at end of file diff --git a/test/testapps/BasicTestApp/Index.cshtml b/test/testapps/BasicTestApp/Index.cshtml index d43fe37668..9086b21fd0 100644 --- a/test/testapps/BasicTestApp/Index.cshtml +++ b/test/testapps/BasicTestApp/Index.cshtml @@ -36,6 +36,9 @@ + + + @if (SelectedComponentType != null)