Skip to content

Commit c96c674

Browse files
test($compile): nested transcludes are 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, only if the first transclude directive is not the first directive found in compilation. See angular#7240
1 parent e9bc51c commit c96c674

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

test/ng/compileSpec.js

+60
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,66 @@ describe('$compile', function() {
14971497
));
14981498

14991499

1500+
describe('nested transcludes', function() {
1501+
1502+
beforeEach(module(function($compileProvider) {
1503+
1504+
$compileProvider.directive('noop', valueFn({}));
1505+
1506+
$compileProvider.directive('t1', valueFn({
1507+
template: '<div noop><div t2><div ng-transclude></div></div></div>',
1508+
transclude: true
1509+
}));
1510+
1511+
$compileProvider.directive('t2', valueFn({
1512+
template: '<div ng-transclude></div>',
1513+
transclude: true
1514+
}));
1515+
1516+
$compileProvider.directive('t1a', valueFn({
1517+
templateUrl: 't1a',
1518+
transclude: true
1519+
}));
1520+
1521+
$compileProvider.directive('t1b', valueFn({
1522+
templateUrl: 't1b',
1523+
transclude: true
1524+
}));
1525+
1526+
$compileProvider.directive('t2a', valueFn({
1527+
templateUrl: 't2a',
1528+
transclude: true
1529+
}));
1530+
}));
1531+
1532+
beforeEach(inject(function($templateCache) {
1533+
$templateCache.put('t1a', '<div noop><div t2><div ng-transclude></div></div></div>');
1534+
$templateCache.put('t1b', '<div noop><div t2a><div ng-transclude></div></div></div>');
1535+
$templateCache.put('t2a', '<div ng-transclude></div>');
1536+
}));
1537+
1538+
1539+
it('should allow nested transclude directives with sync templates', inject(function($compile, $rootScope) {
1540+
element = $compile('<div t1>transcluded content</div>')($rootScope);
1541+
$rootScope.$digest();
1542+
expect(element.text().trim()).toEqual('transcluded content');
1543+
}));
1544+
1545+
it('should allow nested transclude directives with sync templates', inject(function($compile, $rootScope) {
1546+
element = $compile('<div t1a>transcluded content</div>')($rootScope);
1547+
$rootScope.$digest();
1548+
expect(element.text().trim()).toEqual('transcluded content');
1549+
}));
1550+
1551+
it('should allow nested transclude directives with sync templates', inject(function($compile, $rootScope) {
1552+
element = $compile('<div t1b>transcluded content</div>')($rootScope);
1553+
$rootScope.$digest();
1554+
expect(element.text().trim()).toEqual('transcluded content');
1555+
}));
1556+
});
1557+
1558+
1559+
15001560
it("should fail if replacing and template doesn't have a single root element", function() {
15011561
module(function($exceptionHandlerProvider) {
15021562
$exceptionHandlerProvider.mode('log');

0 commit comments

Comments
 (0)