Skip to content
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

@NTaylorMullen

Description

@NTaylorMullen

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&#x2B;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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions