diff --git a/src/Microsoft.AspNet.Razor.Runtime/TagHelpers/TagHelperExecutionContext.cs b/src/Microsoft.AspNet.Razor.Runtime/TagHelpers/TagHelperExecutionContext.cs
index 93087fab3b..fafe33b303 100644
--- a/src/Microsoft.AspNet.Razor.Runtime/TagHelpers/TagHelperExecutionContext.cs
+++ b/src/Microsoft.AspNet.Razor.Runtime/TagHelpers/TagHelperExecutionContext.cs
@@ -19,8 +19,8 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
/// The HTML tag name in the Razor source.
public TagHelperExecutionContext([NotNull] string tagName)
{
- AllAttributes = new Dictionary(StringComparer.Ordinal);
- HTMLAttributes = new Dictionary(StringComparer.Ordinal);
+ AllAttributes = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ HTMLAttributes = new Dictionary(StringComparer.OrdinalIgnoreCase);
_tagHelpers = new List();
TagName = tagName;
}
diff --git a/src/Microsoft.AspNet.Razor.Runtime/TagHelpers/TagHelperOutput.cs b/src/Microsoft.AspNet.Razor.Runtime/TagHelpers/TagHelperOutput.cs
index 8a04c913be..82bc3d78cd 100644
--- a/src/Microsoft.AspNet.Razor.Runtime/TagHelpers/TagHelperOutput.cs
+++ b/src/Microsoft.AspNet.Razor.Runtime/TagHelpers/TagHelperOutput.cs
@@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
internal TagHelperOutput(string tagName)
{
TagName = tagName;
- Attributes = new Dictionary(StringComparer.Ordinal);
+ Attributes = new Dictionary(StringComparer.OrdinalIgnoreCase);
}
// Internal for testing
@@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{
TagName = tagName;
Content = content;
- Attributes = new Dictionary(attributes, StringComparer.Ordinal);
+ Attributes = new Dictionary(attributes, StringComparer.OrdinalIgnoreCase);
}
///
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperExecutionContextTest.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperExecutionContextTest.cs
index 54fe598719..1b51c9ba85 100644
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperExecutionContextTest.cs
+++ b/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperExecutionContextTest.cs
@@ -9,6 +9,49 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
{
public class TagHelperExecutionContextTest
{
+ public static TheoryData DictionaryCaseTestingData
+ {
+ get
+ {
+ return new TheoryData
+ {
+ { "class", "CLaSS" },
+ { "Class", "class" },
+ { "Class", "claSS" }
+ };
+ }
+ }
+
+ [MemberData(nameof(DictionaryCaseTestingData))]
+ public void HtmlAttributes_IgnoresCase(string originalName, string updatedName)
+ {
+ // Arrange
+ var executionContext = new TagHelperExecutionContext("p");
+ executionContext.HTMLAttributes[originalName] = "hello";
+
+ // Act
+ executionContext.HTMLAttributes[updatedName] = "something else";
+
+ // Assert
+ var attribute = Assert.Single(executionContext.HTMLAttributes);
+ Assert.Equal(new KeyValuePair(originalName, "something else"), attribute);
+ }
+
+ [MemberData(nameof(DictionaryCaseTestingData))]
+ public void AllAttributes_IgnoresCase(string originalName, string updatedName)
+ {
+ // Arrange
+ var executionContext = new TagHelperExecutionContext("p");
+ executionContext.AllAttributes[originalName] = false;
+
+ // Act
+ executionContext.AllAttributes[updatedName] = true;
+
+ // Assert
+ var attribute = Assert.Single(executionContext.AllAttributes);
+ Assert.Equal(new KeyValuePair(originalName, true), attribute);
+ }
+
[Fact]
public void AddHtmlAttribute_MaintainsHTMLAttributes()
{
diff --git a/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperOutputTest.cs b/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperOutputTest.cs
index 363ac7424d..cc05acb40c 100644
--- a/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperOutputTest.cs
+++ b/test/Microsoft.AspNet.Razor.Runtime.Test/TagHelpers/TagHelperOutputTest.cs
@@ -208,5 +208,26 @@ namespace Microsoft.AspNet.Razor.Runtime.TagHelpers
// Assert
Assert.Empty(output);
}
+
+ [Theory]
+ [InlineData("class", "ClASs")]
+ [InlineData("CLaSs", "class")]
+ [InlineData("cLaSs", "cLasS")]
+ public void Attributes_IgnoresCase(string originalName, string updateName)
+ {
+ // Arrange
+ var tagHelperOutput = new TagHelperOutput("p",
+ attributes: new Dictionary
+ {
+ { originalName, "btn" },
+ });
+
+ // Act
+ tagHelperOutput.Attributes[updateName] = "super button";
+
+ // Assert
+ var attribute = Assert.Single(tagHelperOutput.Attributes);
+ Assert.Equal(new KeyValuePair(originalName, "super button"), attribute);
+ }
}
}
\ No newline at end of file