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

Commit

Permalink
[Fixes #4317] UrlResolutionTagHelper doesn't work with TagHelpers tha…
Browse files Browse the repository at this point in the history
…t run before and supress output
  • Loading branch information
javiercn committed Mar 30, 2016
1 parent e1abb47 commit 2e8bb07
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
throw new ArgumentNullException(nameof(output));
}

if (output.TagName == null)
{
return;
}

string[] attributeNames;
if (ElementAttributeLookups.TryGetValue(output.TagName, out attributeNames))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,35 @@ public static TheoryData ResolvableUrlData
}
}

[Fact]
public void Process_DoesNothingIfTagNameIsNull()
{
// Arrange
var tagHelperOutput = new TagHelperOutput(
tagName: null,
attributes: new TagHelperAttributeList
{
{ "href", "~/home/index.html" }
},
getChildContentAsync: (useCachedResult, encoder) => Task.FromResult<TagHelperContent>(null));

var tagHelper = new UrlResolutionTagHelper(Mock.Of<IUrlHelperFactory>(), new HtmlTestEncoder());
var context = new TagHelperContext(
allAttributes: new TagHelperAttributeList(
Enumerable.Empty<TagHelperAttribute>()),
items: new Dictionary<object, object>(),
uniqueId: "test");

// Act
tagHelper.Process(context, tagHelperOutput);

// Assert
var attribute = Assert.Single(tagHelperOutput.Attributes);
Assert.Equal("href", attribute.Name, StringComparer.Ordinal);
var attributeValue = Assert.IsType<string>(attribute.Value);
Assert.Equal("~/home/index.html", attributeValue, StringComparer.Ordinal);
}

[Theory]
[MemberData(nameof(ResolvableUrlData))]
public void Process_ResolvesTildeSlashValues(string url, string expectedHref)
Expand Down

0 comments on commit 2e8bb07

Please sign in to comment.