From 880eeeb756693c981e89a94ce91b3c2cd7987c5e Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Thu, 4 Sep 2014 10:57:42 +0100 Subject: [PATCH] fix($compile): render nested transclusion at the root of a template Closes #8914 --- src/ng/compile.js | 4 ++++ test/ng/compileSpec.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/ng/compile.js b/src/ng/compile.js index f89b97feee94..13d0488aa59a 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -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); diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 8fbb10b0cd99..f7d7fd1f4b95 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -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: '' + })); + + $compileProvider.directive('outer', valueFn({ + restrict: 'E', + transclude: true, + template: '' + })); + + })); + + + // Issue #8914 + it('should render nested transclusion at the root of a template', inject(function($compile, $rootScope) { + + element = $compile('
transcluded content
')($rootScope); + $rootScope.$digest(); + expect(element.text()).toEqual('transcluded content'); + + })); + + }); + + describe('nested transcludes', function() { beforeEach(module(function($compileProvider) {