From 27beca7738afe9d1b28a907c9cdb9e96d79f5447 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Sun, 30 Nov 2014 16:52:44 -0800 Subject: [PATCH] Fix #1618, Add asp- prefix to custom attributes of MVC tag helpers - update XML docs to reflect new HTML / custom attribute separation - update `Exception` messages to use new attribute names - update MVC tag helper sample to use new custom attribute names - add missing `` tag helper `throw`s test nits: - reword a few comments and messages for clarity and consistency - use `` sections to describe what's thrown - add "Reviewers" comments about current throws - note `` and `
` are slightly inconsistent with others: `throw` if unable to override specified `href` or `action` attributes; rest `throw` only if custom attributes are inconsistent e.g. `` with `asp-format` but no `asp-for` - create test tag helpers after all property values are available --- .../Views/Home/Create.cshtml | 47 +++-- .../Views/Home/Edit.cshtml | 28 +-- .../Views/Home/Index.cshtml | 22 +-- .../AnchorTagHelper.cs | 47 +++-- .../FormTagHelper.cs | 49 +++--- .../InputTagHelper.cs | 21 ++- .../LabelTagHelper.cs | 6 +- .../Properties/Resources.Designer.cs | 48 ++--- .../Resources.resx | 12 +- .../SelectTagHelper.cs | 17 +- .../TextAreaTagHelper.cs | 7 +- .../ValidationMessageTagHelper.cs | 8 +- .../ValidationSummaryTagHelper.cs | 13 +- .../AnchorTagHelperTest.cs | 86 ++++----- .../FormTagHelperTest.cs | 166 +++++++++--------- .../InputTagHelperTest.cs | 24 +++ .../SelectTagHelperTest.cs | 2 +- .../ValidationSummaryTagHelperTest.cs | 4 +- 18 files changed, 340 insertions(+), 267 deletions(-) diff --git a/samples/TagHelperSample.Web/Views/Home/Create.cshtml b/samples/TagHelperSample.Web/Views/Home/Create.cshtml index 004a242787..ac1733679c 100644 --- a/samples/TagHelperSample.Web/Views/Home/Create.cshtml +++ b/samples/TagHelperSample.Web/Views/Home/Create.cshtml @@ -9,48 +9,47 @@

Create

@* anti-forgery is on by default *@ -@* form will special-case anything that looks like a URI i.e. contains a '/' or doesn't match an action *@ - +@* tag helper will special-case only elements with an "asp-action" or "asp-anti-forgery" attribute. *@ +
@* validation summary tag helper will target just
elements and append the list of errors *@ - @* - i.e. this helper, like helper, has ContentBehavior.Append *@ + @* helper does nothing if model is valid and (client-side validation is disabled or asp-validation-summary="ModelOnly") *@ @* don't need a bound attribute to match Html.ValidationSummary()'s headerTag parameter; users wrap message as they wish *@ @* initially at least, will not remove the
if list isn't generated *@ @* - should helper remove the
if list isn't generated? *@ @* - (Html.ValidationSummary returns empty string despite non-empty message parameter) *@ @* Acceptable values are: "None", "ModelOnly" and "All" *@ -
+
This is my message
@* element will have correct name and id attributes for Id property. unusual part is the constant value. *@ @* - the helper will _not_ override the user-specified "value" attribute *@ - +
- @* no special-case for the "for" attribute; may eventually need to opt out on per-element basis here and in *@ -
-
- diff --git a/samples/TagHelperSample.Web/Views/Home/Edit.cshtml b/samples/TagHelperSample.Web/Views/Home/Edit.cshtml index e3e7eeb9a7..97f277e011 100644 --- a/samples/TagHelperSample.Web/Views/Home/Edit.cshtml +++ b/samples/TagHelperSample.Web/Views/Home/Edit.cshtml @@ -6,27 +6,27 @@
-
- +
+
-
-
-
-
@@ -57,5 +57,5 @@ diff --git a/samples/TagHelperSample.Web/Views/Home/Index.cshtml b/samples/TagHelperSample.Web/Views/Home/Index.cshtml index 65c6265b39..dfc8238e48 100644 --- a/samples/TagHelperSample.Web/Views/Home/Index.cshtml +++ b/samples/TagHelperSample.Web/Views/Home/Index.cshtml @@ -9,36 +9,36 @@ @for (var index = 0; index < Model.Count(); ++index) {
- @Html.LabelFor(m => m[index].Name) @* [index].Name [0].Name *@ + @Html.LabelFor(m => m[index].Name) @Html.TextBoxFor(m => m[index].Name, htmlAttributes: new { disabled = "disabled", @readonly= "readonly" }) - @*
@Html.LabelFor(m => m[index].DateOfBirth) @Html.TextBoxFor(m => m[index].DateOfBirth, format: "{0:yyyy-MM-dd}", htmlAttributes: new { disabled = "disabled", @readonly = "readonly", type="date" }) - @*
@Html.LabelFor(m => m[index].YearsEmployeed) @Html.TextBoxFor(m => m[index].YearsEmployeed, htmlAttributes: new { disabled = "disabled", @readonly = "readonly", type="number" }) - @*
@Html.LabelFor(m => m[index].Blurb) @Html.TextAreaFor(m => m[index].Blurb, htmlAttributes: new { disabled = "disabled", @readonly = "readonly" }) - @*