Skip to content

Commit 90335db

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 e9bc51c commit 90335db

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
@@ -1496,6 +1496,44 @@ describe('$compile', function() {
14961496
}
14971497
));
14981498

1499+
iit('should pass the transcluded content through to ng-transclude', function() {
1500+
1501+
module(function($compileProvider) {
1502+
// This directive transcludes its contents and hopes to use the
1503+
// transcluded content in its template
1504+
$compileProvider.directive('transTest', valueFn({
1505+
templateUrl: 'transTestTemplate',
1506+
transclude: true
1507+
}));
1508+
1509+
// This directive does nothing except to put a directive in the compile
1510+
// element ancestors list between the root $compile node and the trans-test
1511+
// directives' element
1512+
$compileProvider.directive('noop', valueFn({}));
1513+
});
1514+
1515+
inject(function($compile, $rootScope, $templateCache) {
1516+
// This is the template for the trans-test directive, it contains an
1517+
// ng-if, which also uses transclusion, which basically blocks the inner
1518+
// trans-test directive from receiving any transcluded content
1519+
$templateCache.put('transTestTemplate',
1520+
'<div noop>'+
1521+
' <div ng-if="true">'+
1522+
' <div ng-transclude></div>'+
1523+
' _this should be removed_' +
1524+
' </div>'+
1525+
'</div>');
1526+
1527+
element = $compile('<div trans-test>transcluded content</div>')($rootScope);
1528+
1529+
// The ngTransclude:orphan error gets thrown when the digest occurs since this
1530+
// is when the ngTransclude directive tries to use the transcluded function.
1531+
$rootScope.$digest();
1532+
1533+
expect(element.text().trim()).toEqual('transcluded content');
1534+
});
1535+
});
1536+
14991537

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

0 commit comments

Comments
 (0)