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

Attributes don't work in Tag Helper if newline precedes first attribute #484

@Daniel15

Description

@Daniel15

Tag helper:

public class HelloTagHelper : TagHelper
{
    public string First { get; set; }
    public string Second { get; set; }

    public override void Process(TagHelperContext context, TagHelperOutput output)
    {
        output.TagName = "span";
        output.SelfClosing = false;
        output.Attributes.Add("data-first", First);
        output.Attributes.Add("data-second", Second);
    }
}

cshtml:

<hello first="1111" second="2222" />
<hello
    first="1111"
    second="2222"
/>
<hello first="1111"
       second="2222"
/>

Result:

<span data-first="1111" data-second="2222"></span>
<span data-first="" data-second=""></span>
<span data-first="1111" data-second="2222"></span>

The middle <hello /> tag has a newline before the first attribute, which seems to break it (all attributes come through as empty). The final <hello /> only has a newline before the second attribute, which seems to work.

Tested on beta 6.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions