Properly handle attr-value prefix in markup pass

Fixes aspnet/AspNetCoredotnet/aspnetcore-tooling#6480

We were missing handling for the attribute value prefix of a markup
attribute during the markup block rewrite pass. This is properly handled
inside the runtime code writer so you wouldn't see this bug if the
contents of the element were dynamic (and thus could not be rewritten).

Most of the churn here is due to renaming classes. We generally prefer
the term *markup* over *html* in code artifacts, and this was one piece
of new code that refers to html.
\n\nCommit migrated from d16eafd667
This commit is contained in:
Ryan Nowak 2019-01-08 09:42:01 -08:00
parent 77bd9d343c
commit 5b5aa6837f
2 changed files with 4 additions and 2 deletions

View File

@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
//
// Does not preserve insignificant details of the HTML, like tag closing style
// or quote style.
internal class ComponentHtmlBlockPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass
internal class ComponentMarkupBlockPass : ComponentIntermediateNodePassBase, IRazorOptimizationPass
{
// Runs LATE because we want to destroy structure.
public override int Order => 10000;
@ -322,6 +322,8 @@ namespace Microsoft.AspNetCore.Razor.Language.Components
{
for (var i = 0; i < node.Children.Count; i++)
{
Builder.Append(node.Prefix);
if (node.Children[i] is IntermediateToken token)
{
Builder.Append(token.Content);

View File

@ -231,7 +231,7 @@ namespace Microsoft.AspNetCore.Razor.Language
builder.Features.Add(new ComponentTemplateDiagnosticPass());
builder.Features.Add(new ComponentGenericTypePass());
builder.Features.Add(new ComponentChildContentDiagnosticPass());
builder.Features.Add(new ComponentHtmlBlockPass());
builder.Features.Add(new ComponentMarkupBlockPass());
}
private static void LoadExtensions(RazorProjectEngineBuilder builder, IReadOnlyList<RazorExtension> extensions)