Skip to content

Commit 880eeeb

Browse files
fix($compile): render nested transclusion at the root of a template
Closes angular#8914
1 parent ae952fb commit 880eeeb

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/ng/compile.js

+4
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
997997
? JQLitePrototype.clone.call(namespaceAdaptedCompileNodes) // IMPORTANT!!!
998998
: namespaceAdaptedCompileNodes;
999999

1000+
if ( $linkNode.length === 0 && parentBoundTranscludeFn ) {
1001+
$linkNode = parentBoundTranscludeFn(scope);
1002+
}
1003+
10001004
if (transcludeControllers) {
10011005
for (var controllerName in transcludeControllers) {
10021006
$linkNode.data('$' + controllerName + 'Controller', transcludeControllers[controllerName].instance);

test/ng/compileSpec.js

+31
Original file line numberDiff line numberDiff line change
@@ -4927,6 +4927,37 @@ describe('$compile', function() {
49274927
});
49284928

49294929

4930+
describe('collocated nested transcludes', function() {
4931+
4932+
beforeEach(module(function($compileProvider) {
4933+
4934+
$compileProvider.directive('inner', valueFn({
4935+
restrict: 'E',
4936+
transclude: true,
4937+
template: '<u ng-transclude></u>'
4938+
}));
4939+
4940+
$compileProvider.directive('outer', valueFn({
4941+
restrict: 'E',
4942+
transclude: true,
4943+
template: '<a href="#"><inner ng-transclude></inner></a>'
4944+
}));
4945+
4946+
}));
4947+
4948+
4949+
// Issue #8914
4950+
it('should render nested transclusion at the root of a template', inject(function($compile, $rootScope) {
4951+
4952+
element = $compile('<div><outer>transcluded content</outer></div>')($rootScope);
4953+
$rootScope.$digest();
4954+
expect(element.text()).toEqual('transcluded content');
4955+
4956+
}));
4957+
4958+
});
4959+
4960+
49304961
describe('nested transcludes', function() {
49314962

49324963
beforeEach(module(function($compileProvider) {

0 commit comments

Comments
 (0)