Skip to content

Commit 7e56eda

Browse files
test($compile): nested transcludes not passing down tree
If you have two directives that both expect to receive transcluded content the outer directive works but the inner directive never receives a transclusion function. See angular#7240
1 parent d90f83c commit 7e56eda

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/ng/compileSpec.js

+38
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,44 @@ describe('$compile', function() {
14431443
}
14441444
));
14451445

1446+
iit('should pass the transcluded content through to ng-transclude', function() {
1447+
1448+
module(function($compileProvider) {
1449+
// This directive transcludes its contents and hopes to use the
1450+
// transcluded content in its template
1451+
$compileProvider.directive('transTest', valueFn({
1452+
templateUrl: 'transTestTemplate',
1453+
transclude: true
1454+
}));
1455+
1456+
// This directive does nothing except to put a directive in the compile
1457+
// element ancestors list between the root $compile node and the trans-test
1458+
// directives' element
1459+
$compileProvider.directive('noop', valueFn({}));
1460+
});
1461+
1462+
inject(function($compile, $rootScope, $templateCache) {
1463+
// This is the template for the trans-test directive, it contains an
1464+
// ng-if, which also uses transclusion, which basically blocks the inner
1465+
// trans-test directive from receiving any transcluded content
1466+
$templateCache.put('transTestTemplate',
1467+
'<div noop>'+
1468+
' <div ng-if="true">'+
1469+
' <div ng-transclude></div>'+
1470+
' _this should be removed_' +
1471+
' </div>'+
1472+
'</div>');
1473+
1474+
element = $compile('<div trans-test>transcluded content</div>')($rootScope);
1475+
1476+
// The ngTransclude:orphan error gets thrown when the digest occurs since this
1477+
// is when the ngTransclude directive tries to use the transcluded function.
1478+
$rootScope.$digest();
1479+
1480+
expect(element.text().trim()).toEqual('transcluded content');
1481+
});
1482+
});
1483+
14461484

14471485
it("should fail if replacing and template doesn't have a single root element", function() {
14481486
module(function($exceptionHandlerProvider) {

0 commit comments

Comments
 (0)