Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit fcc8b44

Browse files
author
N. Taylor Mullen
committed
Addressed code review comments.
1 parent 6735c30 commit fcc8b44

File tree

8 files changed

+33
-18
lines changed

8 files changed

+33
-18
lines changed

samples/TagHelperSample.Web/Views/Home/Create.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<form asp-anti-forgery="false" asp-action="Create">
1414
<div class="form-horizontal">
1515
@* validation summary tag helper will target just <div/> elements and append the list of errors *@
16-
@* - i.e. this helper, like <select/> helper appends content via *@
16+
@* - i.e. this helper, like <select/> helper appends content. *@
1717
@* helper does nothing if model is valid and (client-side validation is disabled or asp-validation-summary="ModelOnly") *@
1818
@* don't need a bound attribute to match Html.ValidationSummary()'s headerTag parameter; users wrap message as they wish *@
1919
@* initially at least, will not remove the <div/> if list isn't generated *@

src/Microsoft.AspNet.Mvc.TagHelpers/LabelTagHelper.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,16 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
5050
// We check for whitespace to detect scenarios such as:
5151
// <label for="Name">
5252
// </label>
53-
if (string.IsNullOrWhiteSpace(childContent) && string.IsNullOrEmpty(output.Content))
53+
if (string.IsNullOrWhiteSpace(childContent))
5454
{
55-
output.Content = tagBuilder.InnerHtml;
55+
if (string.IsNullOrEmpty(output.Content))
56+
{
57+
output.Content = tagBuilder.InnerHtml;
58+
}
59+
}
60+
else if (string.IsNullOrEmpty(output.Content))
61+
{
62+
output.Content = childContent;
5663
}
5764
}
5865
}

src/Microsoft.AspNet.Mvc.TagHelpers/OptionTagHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ namespace Microsoft.AspNet.Mvc.TagHelpers
1515
/// </summary>
1616
/// <remarks>
1717
/// This <see cref="ITagHelper"/> works in conjunction with <see cref="SelectTagHelper"/>. It reads elements
18-
/// content but does not modify. The only modification it makes is to add a <c>selected</c> attribute in some
19-
/// cases.
18+
/// content but does not modify that content. The only modification it makes is to add a <c>selected</c> attribute
19+
/// in some cases.
2020
/// </remarks>
2121
public class OptionTagHelper : TagHelper
2222
{

src/Microsoft.AspNet.Mvc.TagHelpers/ValidationMessageTagHelper.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,16 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
5252
// We check for whitespace to detect scenarios such as:
5353
// <span validation-for="Name">
5454
// </span>
55-
if (string.IsNullOrWhiteSpace(childContent) && string.IsNullOrEmpty(output.Content))
55+
if (string.IsNullOrWhiteSpace(childContent))
5656
{
57-
output.Content = tagBuilder.InnerHtml;
57+
if (string.IsNullOrWhiteSpace(output.Content))
58+
{
59+
output.Content = tagBuilder.InnerHtml;
60+
}
61+
}
62+
else if (string.IsNullOrEmpty(output.Content))
63+
{
64+
output.Content = childContent;
5865
}
5966
}
6067
}

test/Microsoft.AspNet.Mvc.TagHelpers.Test/LabelTagHelperTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public static TheoryData<object, Type, Func<object>, string, TagHelperOutputCont
6161
{ modelWithText, typeof(Model), () => modelWithText.Text, "Text",
6262
new TagHelperOutputContent(string.Empty, "Hello World", "Hello World", "Text") },
6363
{ modelWithText, typeof(Model), () => modelWithNull.Text, "Text",
64-
new TagHelperOutputContent("Hello World", null, null, "Text") },
64+
new TagHelperOutputContent("Hello World", null, "Hello World", "Text") },
6565
{ modelWithText, typeof(Model), () => modelWithText.Text, "Text",
66-
new TagHelperOutputContent("Hello World", null, null, "Text") },
66+
new TagHelperOutputContent("Hello World", null, "Hello World", "Text") },
6767
{ modelWithText, typeof(Model), () => modelWithNull.Text, "Text",
6868
new TagHelperOutputContent("Hello World1", "Hello World2", "Hello World2", "Text") },
6969
{ modelWithText, typeof(Model), () => modelWithText.Text, "Text",
@@ -82,9 +82,9 @@ public static TheoryData<object, Type, Func<object>, string, TagHelperOutputCont
8282
{ modelWithText, typeof(NestedModel), () => modelWithText.NestedModel.Text, "NestedModel.Text",
8383
new TagHelperOutputContent(string.Empty, "Hello World", "Hello World", "NestedModel_Text") },
8484
{ modelWithNull, typeof(NestedModel), () => modelWithNull.NestedModel.Text, "NestedModel.Text",
85-
new TagHelperOutputContent("Hello World", null, null, "NestedModel_Text") },
85+
new TagHelperOutputContent("Hello World", null, "Hello World", "NestedModel_Text") },
8686
{ modelWithText, typeof(NestedModel), () => modelWithText.NestedModel.Text, "NestedModel.Text",
87-
new TagHelperOutputContent("Hello World", null, null, "NestedModel_Text") },
87+
new TagHelperOutputContent("Hello World", null, "Hello World", "NestedModel_Text") },
8888
{ modelWithNull, typeof(NestedModel), () => modelWithNull.NestedModel.Text, "NestedModel.Text",
8989
new TagHelperOutputContent("Hello World1", "Hello World2", "Hello World2", "NestedModel_Text") },
9090
{ modelWithText, typeof(NestedModel), () => modelWithText.NestedModel.Text, "NestedModel.Text",
@@ -105,9 +105,9 @@ public static TheoryData<object, Type, Func<object>, string, TagHelperOutputCont
105105
{ models, typeof(Model), () => models[1].Text, "[1].Text",
106106
new TagHelperOutputContent(string.Empty, "Hello World", "Hello World", "z1__Text") },
107107
{ models, typeof(Model), () => models[0].Text, "[0].Text",
108-
new TagHelperOutputContent("Hello World", null, null, "z0__Text") },
108+
new TagHelperOutputContent("Hello World", null, "Hello World", "z0__Text") },
109109
{ models, typeof(Model), () => models[1].Text, "[1].Text",
110-
new TagHelperOutputContent("Hello World", null, null, "z1__Text") },
110+
new TagHelperOutputContent("Hello World", null, "Hello World", "z1__Text") },
111111
{ models, typeof(Model), () => models[0].Text, "[0].Text",
112112
new TagHelperOutputContent("Hello World1", "Hello World2", "Hello World2", "z0__Text") },
113113
{ models, typeof(Model), () => models[1].Text, "[1].Text",
@@ -126,9 +126,9 @@ public static TheoryData<object, Type, Func<object>, string, TagHelperOutputCont
126126
{ models, typeof(NestedModel), () => models[1].NestedModel.Text, "[1].NestedModel.Text",
127127
new TagHelperOutputContent(string.Empty, "Hello World", "Hello World", "z1__NestedModel_Text") },
128128
{ models, typeof(NestedModel), () => models[0].NestedModel.Text, "[0].NestedModel.Text",
129-
new TagHelperOutputContent("Hello World", null, null, "z0__NestedModel_Text") },
129+
new TagHelperOutputContent("Hello World", null, "Hello World", "z0__NestedModel_Text") },
130130
{ models, typeof(NestedModel), () => models[1].NestedModel.Text, "[1].NestedModel.Text",
131-
new TagHelperOutputContent("Hello World", null, null, "z1__NestedModel_Text") },
131+
new TagHelperOutputContent("Hello World", null, "Hello World", "z1__NestedModel_Text") },
132132
{ models, typeof(NestedModel), () => models[0].NestedModel.Text, "[0].NestedModel.Text",
133133
new TagHelperOutputContent("Hello World1", "Hello World2", "Hello World2", "z0__NestedModel_Text") },
134134
{ models, typeof(NestedModel), () => models[1].NestedModel.Text, "[1].NestedModel.Text",

test/Microsoft.AspNet.Mvc.TagHelpers.Test/ValidationMessageTagHelperTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ public async Task ProcessAsync_CallsIntoGenerateValidationMessageWithExpectedPar
122122
}
123123

124124
[Theory]
125-
[InlineData("Content of validation message", null, null)]
125+
[InlineData("Content of validation message", null, "Content of validation message")]
126126
[InlineData("Content of validation message", "Some Content", "Some Content")]
127127
[InlineData("\r\n \r\n", "", "New HTML")]
128+
[InlineData("\r\n \r\n", "\r\n \r\n", "New HTML")]
128129
[InlineData("\r\n \r\n", "Some Content", "Some Content")]
129130
public async Task ProcessAsync_MergesTagBuilderFromGenerateValidationMessage(
130131
string childContent, string outputContent, string expectedOutputContent)

test/WebSites/ActivatorWebSite/TagHelpers/HiddenTagHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System.Threading.Tasks;
45
using Microsoft.AspNet.Mvc;
56
using Microsoft.AspNet.Mvc.Rendering;
67
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
7-
using System.Threading.Tasks;
88

99
namespace ActivatorWebSite.TagHelpers
1010
{

test/WebSites/ActivatorWebSite/TagHelpers/RepeatContentTagHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System.Threading.Tasks;
45
using Microsoft.AspNet.Mvc;
56
using Microsoft.AspNet.Mvc.Rendering;
67
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
7-
using System.Threading.Tasks;
88

99
namespace ActivatorWebSite.TagHelpers
1010
{

0 commit comments

Comments
 (0)