fix($compile): render nested transclusion at the root of a template

Closes #8914
Closes #8925
This commit is contained in:
Peter Bacon Darwin
2014-09-04 13:27:19 +01:00
parent 68a09ba74d
commit 9d9cdfb575
2 changed files with 33 additions and 0 deletions
+4
View File
@@ -847,6 +847,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
? JQLitePrototype.clone.call($compileNodes) // IMPORTANT!!!
: $compileNodes;
if ( $linkNode.length === 0 && parentBoundTranscludeFn ) {
$linkNode = parentBoundTranscludeFn(scope);
}
forEach(transcludeControllers, function(instance, name) {
$linkNode.data('$' + name + 'Controller', instance);
});
+29
View File
@@ -4097,6 +4097,35 @@ describe('$compile', function() {
});
describe('collocated nested transcludes', function() {
beforeEach(module(function($compileProvider) {
$compileProvider.directive('inner', valueFn({
transclude: true,
template: '<div ng-transclude></div>'
}));
$compileProvider.directive('outer', valueFn({
transclude: true,
template: '<a href="#"><div inner ng-transclude></div></a>'
}));
}));
// Issue #8914
it('should render nested transclusion at the root of a template', inject(function($compile, $rootScope) {
element = $compile('<div><div outer>transcluded content</div></div>')($rootScope);
$rootScope.$digest();
expect(element.text()).toEqual('transcluded content');
}));
});
describe('nested transcludes', function() {
beforeEach(module(function($compileProvider) {