[Fixes #5421] Visit children when accepting TagHelperChunk

- Fixes ViewComponentTagHelpers in nested scenarios
This commit is contained in:
Ajay Bhargav Baaskaran 2016-10-18 10:42:55 -07:00
parent ae5f5739f7
commit 61de7fec6f
4 changed files with 12 additions and 4 deletions

View File

@ -40,7 +40,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Host.Internal
tagHelperChunk.Descriptors = Decorate(tagHelperChunk.Descriptors); tagHelperChunk.Descriptors = Decorate(tagHelperChunk.Descriptors);
} }
base.Accept(chunk); var parentChunk = chunk as ParentChunk;
if (parentChunk != null)
{
Visit(parentChunk);
}
} }
protected override void Visit(ParentChunk parentChunk) protected override void Visit(ParentChunk parentChunk)

View File

@ -41,7 +41,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Host.Internal
Visit(tagHelperChunk); Visit(tagHelperChunk);
} }
base.Accept(chunk); var parentChunk = chunk as ParentChunk;
if (parentChunk != null)
{
Visit(parentChunk);
}
} }
protected override void Visit(ParentChunk parentChunk) protected override void Visit(ParentChunk parentChunk)

View File

@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Host
private static ParentChunk GetNestedViewComponentTagHelperChunk(string name, bool visitedTagHelperChunks) private static ParentChunk GetNestedViewComponentTagHelperChunk(string name, bool visitedTagHelperChunks)
{ {
var parentChunk = new ParentChunk(); var parentChunk = GetTagHelperChunk("blah");
var tagHelperChunk = GetViewComponentTagHelperChunk(name, visitedTagHelperChunks); var tagHelperChunk = GetViewComponentTagHelperChunk(name, visitedTagHelperChunks);
parentChunk.Children.Add(tagHelperChunk); parentChunk.Children.Add(tagHelperChunk);
return parentChunk; return parentChunk;

View File

@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Host.Test
// Test the parent chunk with view component tag helper inside, Foo. // Test the parent chunk with view component tag helper inside, Foo.
var expectedParentChunk = (ParentChunk)expectedChunks[1]; var expectedParentChunk = (ParentChunk)expectedChunks[1];
var resultParentChunk = Assert.IsType<ParentChunk>(resultChunks[1]); var resultParentChunk = Assert.IsType<TagHelperChunk>(resultChunks[1]);
Assert.Single(resultParentChunk.Children); Assert.Single(resultParentChunk.Children);
expectedTagHelperChunk = (TagHelperChunk)expectedParentChunk.Children.First(); expectedTagHelperChunk = (TagHelperChunk)expectedParentChunk.Children.First();