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

Commit 9d9cdfb

Browse files
fix($compile): render nested transclusion at the root of a template
Closes #8914 Closes #8925
1 parent 68a09ba commit 9d9cdfb

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/ng/compile.js

+4
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
847847
? JQLitePrototype.clone.call($compileNodes) // IMPORTANT!!!
848848
: $compileNodes;
849849

850+
if ( $linkNode.length === 0 && parentBoundTranscludeFn ) {
851+
$linkNode = parentBoundTranscludeFn(scope);
852+
}
853+
850854
forEach(transcludeControllers, function(instance, name) {
851855
$linkNode.data('$' + name + 'Controller', instance);
852856
});

test/ng/compileSpec.js

+29
Original file line numberDiff line numberDiff line change
@@ -4097,6 +4097,35 @@ describe('$compile', function() {
40974097
});
40984098

40994099

4100+
describe('collocated nested transcludes', function() {
4101+
4102+
beforeEach(module(function($compileProvider) {
4103+
4104+
$compileProvider.directive('inner', valueFn({
4105+
transclude: true,
4106+
template: '<div ng-transclude></div>'
4107+
}));
4108+
4109+
$compileProvider.directive('outer', valueFn({
4110+
transclude: true,
4111+
template: '<a href="#"><div inner ng-transclude></div></a>'
4112+
}));
4113+
4114+
}));
4115+
4116+
4117+
// Issue #8914
4118+
it('should render nested transclusion at the root of a template', inject(function($compile, $rootScope) {
4119+
4120+
element = $compile('<div><div outer>transcluded content</div></div>')($rootScope);
4121+
$rootScope.$digest();
4122+
expect(element.text()).toEqual('transcluded content');
4123+
4124+
}));
4125+
4126+
});
4127+
4128+
41004129
describe('nested transcludes', function() {
41014130

41024131
beforeEach(module(function($compileProvider) {

0 commit comments

Comments
 (0)