Ignoring markup comments during validation

This commit is contained in:
Artak Mkrtchyan 2018-02-12 22:03:53 -08:00
parent e6f68eb244
commit 41b7d90ea8
No known key found for this signature in database
GPG Key ID: 64D580ACBA8CA645
2 changed files with 13 additions and 5 deletions

View File

@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
continue;
}
}
else
else if (!IsCommentTag((Span)child))
{
ValidateParentAllowsContent((Span)child, errorSink);
}
@ -817,6 +817,11 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
return relevantSymbol.Type == HtmlSymbolType.ForwardSlash;
}
private static bool IsCommentTag(Span span)
{
return span.Content.StartsWith("<!--");
}
private static void EnsureTagBlock(Block tagBlock)
{
Debug.Assert(tagBlock.Type == BlockKindInternal.Tag);

View File

@ -1113,9 +1113,9 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
{
// Arrangestring documentContent,
IEnumerable<string> allowedChildren = new List<string> { "b" };
string literalPrefix = "";
string literal = "asdf";
string commentOutput = $"<!--Hello World-->";
string expectedOutput = $"<p>{literalPrefix}{commentOutput}<b>asdf</b></p>";
string expectedOutput = $"<p><b>{literal}</b>{commentOutput}</p>";
var pTagHelperBuilder = TagHelperDescriptorBuilder
.Create("PTagHelper", "SomeAssembly")
@ -1127,7 +1127,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
var descriptors = new TagHelperDescriptor[]
{
pTagHelperBuilder.Build()
pTagHelperBuilder.Build()
};
var factory = new SpanFactory();
@ -1135,7 +1135,10 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
var expectedMarkup = new MarkupBlock(
new MarkupTagHelperBlock("p",
factory.Markup($"{literalPrefix}{commentOutput}")));
blockFactory.MarkupTagBlock("<b>"),
factory.Markup(literal),
blockFactory.MarkupTagBlock("</b>"),
factory.Markup(commentOutput)));
// Act & Assert
EvaluateData(