[Fixes #2547] Fixed attribute value prefix with dynamic content being ignored

This commit is contained in:
Ajay Bhargav Baaskaran 2015-05-15 16:08:48 -07:00
parent a0813faa48
commit 48e0b3261c
6 changed files with 40 additions and 2 deletions

View File

@ -548,7 +548,8 @@ namespace Microsoft.AspNet.Mvc.Razor
WritePositionTaggedLiteral(writer, prefix);
first = false;
}
else
if (!string.IsNullOrEmpty(attrVal.Prefix))
{
WritePositionTaggedLiteral(writer, attrVal.Prefix);
}

View File

@ -76,6 +76,24 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
Assert.Equal(expectedContent, responseContent);
}
[Fact]
public async Task ViewWithAttributePrefix_RendersWithoutIgnoringPrefix()
{
// Arrange
var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient();
var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
"compiler/resources/BasicWebSite.Home.ViewWithPrefixedAttributeValue.html");
// Act
var response = await client.GetAsync("http://localhost/Home/ViewWithPrefixedAttributeValue");
var responseContent = await response.Content.ReadAsStringAsync();
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Equal(expectedContent, responseContent);
}
[Fact]
public async Task CanReturn_ResultsWithoutContent()
{

View File

@ -0,0 +1,5 @@
<span foo=" abc" />
<span bar=" Baz" />
<span baz=" Baz Baz" />

View File

@ -667,6 +667,8 @@ namespace Microsoft.AspNet.Mvc.Razor
var sequence = new MockSequence();
context.InSequence(sequence).Setup(f => f.BeginContext(0, 6, true)).Verifiable();
context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable();
context.InSequence(sequence).Setup(f => f.BeginContext(0, 6, true)).Verifiable();
context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable();
context.InSequence(sequence).Setup(f => f.BeginContext(8, 14, true)).Verifiable();
context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable();
context.InSequence(sequence).Setup(f => f.BeginContext(22, 7, true)).Verifiable();

View File

@ -86,7 +86,12 @@ namespace BasicWebSite.Controllers
{
return View();
}
public IActionResult ViewWithPrefixedAttributeValue()
{
return View();
}
public string GetApplicationDescription()
{
var actionDescriptor = (ControllerActionDescriptor)ActionContext.ActionDescriptor;

View File

@ -0,0 +1,7 @@
@{
var attrValue = "Baz";
}
<span foo=" abc" />
<span bar=" @attrValue" />
<span baz=" @attrValue @attrValue" />