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 86c6be8 commit 6d1e7cd
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 @@ -997,6 +997,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
? JQLitePrototype.clone.call(namespaceAdaptedCompileNodes) // IMPORTANT!!!
: namespaceAdaptedCompileNodes;

if ( $linkNode.length === 0 && parentBoundTranscludeFn ) {
$linkNode = parentBoundTranscludeFn(scope);
}

if (transcludeControllers) {
for (var controllerName in transcludeControllers) {
$linkNode.data('$' + controllerName + 'Controller', transcludeControllers[controllerName].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 @@ -4927,6 +4927,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 6d1e7cd

Please sign in to comment.