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

Commit

Permalink
Allow null parent tag when calling GetTagHelpersGivenParent.
Browse files Browse the repository at this point in the history
- A `null` parent tag in all of our other API represents "any" parent tag, or in this case "root". Prior to this change we'd expect the caller to do their own verification of the parent and then assume all `TagHelperDescriptor`s are valid; this isn't sufficient because only our code base should have that knowledge.

#1188
  • Loading branch information
NTaylorMullen committed Apr 7, 2017
1 parent af3cf49 commit 96d97f6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ public override IReadOnlyList<TagHelperDescriptor> GetTagHelpersGivenParent(TagH
throw new ArgumentNullException(nameof(documentContext));
}

if (parentTag == null)
{
throw new ArgumentNullException(nameof(parentTag));
}

var matchingDescriptors = new List<TagHelperDescriptor>();
var descriptors = documentContext?.TagHelpers;
if (descriptors?.Count == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,26 @@ public void GetTagHelpersGivenTag_RestrictsTagHelpersBasedOnParent()
Assert.Equal(expectedDescriptors, descriptors, TagHelperDescriptorComparer.CaseSensitive);
}

[Fact]
public void GetTagHelpersGivenParent_AllowsRootParentTag()
{
// Arrange
var documentDescriptors = new[]
{
ITagHelperDescriptorBuilder.Create("TestType", "TestAssembly")
.TagMatchingRule(rule => rule.RequireTagName("div"))
.Build()
};
var documentContext = TagHelperDocumentContext.Create(string.Empty, documentDescriptors);
var service = new DefaultTagHelperFactsService();

// Act
var descriptors = service.GetTagHelpersGivenParent(documentContext, parentTag: null /* root */);

// Assert
Assert.Equal(documentDescriptors, descriptors, TagHelperDescriptorComparer.CaseSensitive);
}

[Fact]
public void GetTagHelpersGivenParent_AllowsUnspecifiedParentTagHelpers()
{
Expand Down

0 comments on commit 96d97f6

Please sign in to comment.