Skip to content

Commit

Permalink
fix($compile): render nested transclusion at the root of a template
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Sep 4, 2014
1 parent 239d0b1 commit 930b013
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
29 changes: 29 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 930b013

Please sign in to comment.