Skip to content

Commit

Permalink
test($compile): nested transcludes not passing down tree
Browse files Browse the repository at this point in the history
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
  • Loading branch information
petebacondarwin committed May 7, 2014
1 parent d90f83c commit 7e56eda
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,44 @@ describe('$compile', function() {
}
));

iit('should pass the transcluded content through to ng-transclude', function() {

module(function($compileProvider) {
// This directive transcludes its contents and hopes to use the
// transcluded content in its template
$compileProvider.directive('transTest', valueFn({
templateUrl: 'transTestTemplate',
transclude: true
}));

// This directive does nothing except to put a directive in the compile
// element ancestors list between the root $compile node and the trans-test
// directives' element
$compileProvider.directive('noop', valueFn({}));
});

inject(function($compile, $rootScope, $templateCache) {
// This is the template for the trans-test directive, it contains an
// ng-if, which also uses transclusion, which basically blocks the inner
// trans-test directive from receiving any transcluded content
$templateCache.put('transTestTemplate',
'<div noop>'+
' <div ng-if="true">'+
' <div ng-transclude></div>'+
' _this should be removed_' +
' </div>'+
'</div>');

element = $compile('<div trans-test>transcluded content</div>')($rootScope);

// The ngTransclude:orphan error gets thrown when the digest occurs since this
// is when the ngTransclude directive tries to use the transcluded function.
$rootScope.$digest();

expect(element.text().trim()).toEqual('transcluded content');
});
});


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

0 comments on commit 7e56eda

Please sign in to comment.