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

Commit

Permalink
[Fixes #2547] Fixed attribute value prefix with dynamic content being…
Browse files Browse the repository at this point in the history
… ignored
  • Loading branch information
ajaybhargavb committed May 19, 2015
1 parent a0813fa commit 48e0b32
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ public virtual void WriteAttributeTo(
WritePositionTaggedLiteral(writer, prefix);
first = false;
}
else

if (!string.IsNullOrEmpty(attrVal.Prefix))
{
WritePositionTaggedLiteral(writer, attrVal.Prefix);
}
Expand Down
18 changes: 18 additions & 0 deletions test/Microsoft.AspNet.Mvc.FunctionalTests/BasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ public async Task CanRender_SimpleViews()
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()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


<span foo=" abc" />
<span bar=" Baz" />
<span baz=" Baz Baz" />
2 changes: 2 additions & 0 deletions test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@ public async Task WriteAttribute_CallsBeginAndEndContext_OnPageExecutionListener
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();
Expand Down
7 changes: 6 additions & 1 deletion test/WebSites/BasicWebSite/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ public IActionResult JsonTextInView()
{
return View();
}


public IActionResult ViewWithPrefixedAttributeValue()
{
return View();
}

public string GetApplicationDescription()
{
var actionDescriptor = (ControllerActionDescriptor)ActionContext.ActionDescriptor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@{
var attrValue = "Baz";
}

<span foo=" abc" />
<span bar=" @attrValue" />
<span baz=" @attrValue @attrValue" />

0 comments on commit 48e0b32

Please sign in to comment.