Remove special casing of '*' in TagHelperDescriptorProvider.
- Requesting a '*' tagName from the TagHelperDescriptorProvider could only happen if a user was directly calling into it (extremely unlikely). Therefore I've removed the special casing to make the logic more simple. - Removed tests that expected this behavior. #324
This commit is contained in:
parent
ed92b6992d
commit
3ba92523ff
|
|
@ -66,17 +66,12 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
||||||
descriptors = catchAllDescriptors;
|
descriptors = catchAllDescriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the requested tag name is the catch-all target, we shouldn't do the work of concatenating extra
|
// If we have a tag name associated with the requested name, we need to combine matchingDescriptors
|
||||||
// descriptors.
|
// with all the catch-all descriptors.
|
||||||
if (!tagName.Equals(ElementCatchAllTarget, StringComparison.OrdinalIgnoreCase))
|
HashSet<TagHelperDescriptor> matchingDescriptors;
|
||||||
|
if (_registrations.TryGetValue(tagName, out matchingDescriptors))
|
||||||
{
|
{
|
||||||
// If we have a tag name associated with the requested name, we need to combine matchingDescriptors
|
descriptors = matchingDescriptors.Concat(descriptors);
|
||||||
// with all the catch-all descriptors.
|
|
||||||
HashSet<TagHelperDescriptor> matchingDescriptors;
|
|
||||||
if (_registrations.TryGetValue(tagName, out matchingDescriptors))
|
|
||||||
{
|
|
||||||
descriptors = matchingDescriptors.Concat(descriptors);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var applicableDescriptors = ApplyRequiredAttributes(descriptors, attributeNames);
|
var applicableDescriptors = ApplyRequiredAttributes(descriptors, attributeNames);
|
||||||
|
|
|
||||||
|
|
@ -86,30 +86,6 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
||||||
defaultAvailableDescriptors,
|
defaultAvailableDescriptors,
|
||||||
new[] { inputDescriptor, catchAllDescriptor }
|
new[] { inputDescriptor, catchAllDescriptor }
|
||||||
},
|
},
|
||||||
{
|
|
||||||
TagHelperDescriptorProvider.ElementCatchAllTarget,
|
|
||||||
new[] { "custom" },
|
|
||||||
defaultAvailableDescriptors,
|
|
||||||
Enumerable.Empty<TagHelperDescriptor>()
|
|
||||||
},
|
|
||||||
{
|
|
||||||
TagHelperDescriptorProvider.ElementCatchAllTarget,
|
|
||||||
new[] { "class" },
|
|
||||||
defaultAvailableDescriptors,
|
|
||||||
new[] { catchAllDescriptor }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
TagHelperDescriptorProvider.ElementCatchAllTarget,
|
|
||||||
new[] { "class", "style" },
|
|
||||||
defaultAvailableDescriptors,
|
|
||||||
new[] { catchAllDescriptor }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
TagHelperDescriptorProvider.ElementCatchAllTarget,
|
|
||||||
new[] { "class", "custom" },
|
|
||||||
defaultAvailableDescriptors,
|
|
||||||
new[] { catchAllDescriptor, catchAllDescriptor2 }
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"input",
|
"input",
|
||||||
new[] { "nodashprefixA" },
|
new[] { "nodashprefixA" },
|
||||||
|
|
@ -291,27 +267,6 @@ namespace Microsoft.AspNet.Razor.TagHelpers
|
||||||
Assert.Empty(retrievedDescriptors);
|
Assert.Empty(retrievedDescriptors);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void GetDescriptors_DoesNotReturnNonCatchAllTagsForCatchAll()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
var divDescriptor = new TagHelperDescriptor("div", "foo1", "SomeAssembly");
|
|
||||||
var spanDescriptor = new TagHelperDescriptor("span", "foo2", "SomeAssembly");
|
|
||||||
var catchAllDescriptor = new TagHelperDescriptor(
|
|
||||||
TagHelperDescriptorProvider.ElementCatchAllTarget,
|
|
||||||
"foo3",
|
|
||||||
"SomeAssembly");
|
|
||||||
var descriptors = new TagHelperDescriptor[] { divDescriptor, spanDescriptor, catchAllDescriptor };
|
|
||||||
var provider = new TagHelperDescriptorProvider(descriptors);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var retrievedDescriptors = provider.GetDescriptors(TagHelperDescriptorProvider.ElementCatchAllTarget, attributeNames: Enumerable.Empty<string>());
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
var descriptor = Assert.Single(retrievedDescriptors);
|
|
||||||
Assert.Same(catchAllDescriptor, descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GetDescriptors_ReturnsCatchAllsWithEveryTagName()
|
public void GetDescriptors_ReturnsCatchAllsWithEveryTagName()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue