In RazorCompiler, allow HTML comments

This commit is contained in:
Steve Sanderson 2018-02-20 14:57:31 +00:00
parent fd5875c5e7
commit 78a19c07e9
3 changed files with 23 additions and 1 deletions

View File

@ -1,2 +1,8 @@
@using Microsoft.AspNetCore.Blazor.Browser.Routing
<c:BrowserRouter AppAssembly=@(typeof(StandaloneApp.Program).Assembly) PagesNamespace=@("StandaloneApp.Pages") />
<!--
Configuring this stuff here is temporary. Later we'll move the app config
into Program.cs, and it won't be necessary to specify AppAssembly.
-->
<c:BrowserRouter
AppAssembly=@(typeof(StandaloneApp.Program).Assembly)
PagesNamespace=@("StandaloneApp.Pages") />

View File

@ -285,6 +285,9 @@ namespace Microsoft.AspNetCore.Blazor.Razor
break;
}
case HtmlTokenType.Comment:
break;
default:
throw new InvalidCastException($"Unsupported token type: {nextToken.Type.ToString()}");
}

View File

@ -187,6 +187,19 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
frame => AssertFrame.Element(frame, "img", 1, 1));
}
[Fact]
public void SupportsComments()
{
// Arrange/Act
var component = CompileToComponent("Start<!-- My comment -->End");
var frames = GetRenderTree(component);
// Assert
Assert.Collection(frames,
frame => AssertFrame.Text(frame, "Start", 0),
frame => AssertFrame.Text(frame, "End", 1));
}
[Fact]
public void SupportsAttributesWithLiteralValues()
{