Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($compile): render nested transclusion at the root of a template
Browse files Browse the repository at this point in the history
Closes #8914
Closes #8925
  • Loading branch information
petebacondarwin committed Sep 4, 2014
1 parent 7e02fa0 commit 466320f
Show file tree
Hide file tree
Showing 2 changed files with 35 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
31 changes: 31 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4097,6 +4097,37 @@ describe('$compile', function() {
});


describe('collocated nested transcludes', function() {

beforeEach(module(function($compileProvider) {

$compileProvider.directive('inner', valueFn({
restrict: 'E',
transclude: true,
template: '<u ng-transclude></u>'
}));

$compileProvider.directive('outer', valueFn({
restrict: 'E',
transclude: true,
template: '<a href="#"><inner ng-transclude></inner></a>'
}));

}));


// Issue #8914
it('should render nested transclusion at the root of a template', inject(function($compile, $rootScope) {

element = $compile('<div><outer>transcluded content</outer></div>')($rootScope);
$rootScope.$digest();
expect(element.text()).toEqual('transcluded content');

}));

});


describe('nested transcludes', function() {

beforeEach(module(function($compileProvider) {
Expand Down

0 comments on commit 466320f

Please sign in to comment.