This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
InputTagHelper doesn't copy pre-existing attributes correctly for checkboxes. #5981
Closed
Description
Given the following TagHelper
:
[HtmlTargetElement("input", Attributes = "asp-for,[type=checkbox]")]
public class FooTagHelper : TagHelper
{
public override int Order => -2000;
public override void Process(TagHelperContext context, TagHelperOutput output)
{
var tb = new TagBuilder("input");
tb.AddCssClass("myclass");
output.MergeAttributes(tb);
}
}
And the following source:
<input asp-for="BoolVal" class="my-control" type="checkbox" />
You end up getting an invalid class attribute value:
<input checked="checked" class="Microsoft.AspNetCore.Mvc.TagHelpers.TagHelperOutputExtensions+ClassAttributeHtmlContent" data-val="true" data-val-required="The BoolVal field is required." id="BoolVal" name="BoolVal" type="checkbox" value="true" /><input name="BoolVal" type="hidden" value="false" />
This is because of how we copy the pre-existing output attributes.