lonix
lonix

Reputation: 20699

Custom tag helper automatically removes attributes from markup

Consider a custom tag helper with this:

[HtmlTargetElement("a", Attributes = "custom")]
public class CustomTagHelper : TagHelper
{

  [HtmlAttributeName("foo")]
  public string? Foo { get; set; }

  // ...

And this razor markup:

<a custom foo="bar" ... 

The rendered markup:

<a ... 

The foo attribute is missing in the rendered markup. If I remove the Foo property, it remains. So the tag helper removes such public properties.

I can't find anything in the docs that describe this behaviour, so I don't know whether it's normal or the problem lies elsewhere.

Is this expected behaviour? If so, why does it work this way?

(My workaround is to re-add that attribute manually.)

Upvotes: 0

Views: 41

Answers (0)

Related Questions