[Fixes #266] Maintain HTML provided case for TagHelper attributes

This commit is contained in:
Ajay Bhargav Baaskaran 2015-05-13 12:19:18 -07:00
parent 4d80c96f9c
commit 7bd338fc4a
4 changed files with 10 additions and 8 deletions

View File

@ -200,7 +200,8 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
if (matchingAttributes.Any())
{
// First attribute wins, even if there's duplicates.
var attributeValueChunk = matchingAttributes.First().Value;
var firstAttribute = matchingAttributes.First();
var attributeValueChunk = firstAttribute.Value;
var attributeValueRecorded = htmlAttributeValues.ContainsKey(attributeDescriptor.Name);
@ -293,12 +294,13 @@ namespace Microsoft.AspNet.Razor.Generator.Compiler.CSharp
continue;
}
var attributeName = firstAttribute.Key;
// We need to inform the context of the attribute value.
_writer
.WriteStartInstanceMethodInvocation(
ExecutionContextVariableName,
_tagHelperContext.ExecutionContextAddTagHelperAttributeMethodName)
.WriteStringLiteral(attributeDescriptor.Name)
.WriteStringLiteral(attributeName)
.WriteParameterSeparator()
.Write(valueAccessor)
.WriteEndMethodInvocation();

View File

@ -1,4 +1,4 @@
#pragma checksum "ComplexTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "e63f87bb14f278343a07e293df68e44e88600352"
#pragma checksum "ComplexTagHelpers.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5832e3fc8fa5fa77f49c7bdb26fb90a1dd2d6eb0"
namespace TestOutput
{
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
@ -140,7 +140,7 @@ WriteLiteral(true ? "checkbox" : "anything");
#line hidden
__tagHelperStringValueBuffer = EndTagHelperWritingScope();
__InputTagHelper.Type = __tagHelperStringValueBuffer.ToString();
__tagHelperExecutionContext.AddTagHelperAttribute("type", __InputTagHelper.Type);
__tagHelperExecutionContext.AddTagHelperAttribute("tYPe", __InputTagHelper.Type);
__InputTagHelper2 = CreateTagHelper<InputTagHelper2>();
__tagHelperExecutionContext.Add(__InputTagHelper2);
__InputTagHelper2.Type = __InputTagHelper.Type;
@ -237,7 +237,7 @@ __InputTagHelper2.Checked = @object;
#line default
#line hidden
__tagHelperExecutionContext.AddTagHelperAttribute("checked", __InputTagHelper2.Checked);
__tagHelperExecutionContext.AddTagHelperAttribute("ChecKED", __InputTagHelper2.Checked);
__tagHelperExecutionContext.Output = await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
await WriteTagHelperAsync(__tagHelperExecutionContext);
__tagHelperExecutionContext = __tagHelperScopeManager.End();

View File

@ -70,7 +70,7 @@ WriteLiteral(DateTime.Now);
#line hidden
__tagHelperStringValueBuffer = EndTagHelperWritingScope();
__MyTagHelper.BoundProperty = __tagHelperStringValueBuffer.ToString();
__tagHelperExecutionContext.AddTagHelperAttribute("BoundProperty", __MyTagHelper.BoundProperty);
__tagHelperExecutionContext.AddTagHelperAttribute("boundproperty", __MyTagHelper.BoundProperty);
StartTagHelperWritingScope();
WriteLiteral("Current Time: ");
#line 9 "TagHelpersInSection.cshtml"

View File

@ -14,13 +14,13 @@
else
{
<p>Current Time: <input type=@checkbox checked=true /></p>
<input type='@(true ? "checkbox" : "anything")' />
<input tYPe='@(true ? "checkbox" : "anything")' />
<input type='@if(true) { <text>checkbox</text> } else { <text>anything</text> }' />
}
</p>
<p age="@DateTimeOffset.Now.Year - 1970">
@{ var @object = false;}
<input checked="@(@object)" />
<input ChecKED="@(@object)" />
</p>
<p age="-1970 + @DateTimeOffset.Now.Year">
<input checked="@(DateTimeOffset.Now.Year > 2014)" />