@@ -1498,6 +1498,59 @@ describe('$compile', function() {
1498
1498
1499
1499
iit ( 'should pass the transcluded content through to ng-transclude' , function ( ) {
1500
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
+
1510
+ inject ( function ( $compile , $rootScope , $templateCache ) {
1511
+ // This is the template for the trans-test directive, it contains an
1512
+ // ng-if, which also uses transclusion, which basically blocks the inner
1513
+ // trans-test directive from receiving any transcluded content
1514
+ $templateCache . put ( 'transTestTemplate' ,
1515
+ ' <div ng-if="true">' +
1516
+ ' <div ng-transclude></div>' +
1517
+ '</div>' ) ;
1518
+
1519
+ element = $compile ( '<div trans-test>transcluded content</div>' ) ( $rootScope ) ;
1520
+
1521
+ // The ngTransclude:orphan error gets thrown when the digest occurs since this
1522
+ // is when the ngTransclude directive tries to use the transcluded function.
1523
+ $rootScope . $digest ( ) ;
1524
+
1525
+ expect ( element . text ( ) . trim ( ) ) . toEqual ( 'transcluded content' ) ;
1526
+ } ) ;
1527
+ } ) ;
1528
+
1529
+
1530
+ iit ( 'nested ngIfs should transclude correctly' , function ( ) {
1531
+
1532
+ module ( function ( $compileProvider ) {
1533
+ // This directive does nothing except to put a directive in the compile
1534
+ // element ancestors list between the root $compile node and the trans-test
1535
+ // directives' element
1536
+ $compileProvider . directive ( 'noop' , valueFn ( { } ) ) ;
1537
+ } ) ;
1538
+
1539
+ inject ( function ( $compile , $rootScope ) {
1540
+ element = $compile ( '<div noop><div ng-if="true">outer<div ng-if="true">inner</div></div></div>' ) ( $rootScope ) ;
1541
+
1542
+ // The ngTransclude:orphan error gets thrown when the digest occurs since this
1543
+ // is when the ngTransclude directive tries to use the transcluded function.
1544
+ $rootScope . $digest ( ) ;
1545
+
1546
+ expect ( element . text ( ) . trim ( ) ) . toEqual ( 'outerinner' ) ;
1547
+ } ) ;
1548
+ } ) ;
1549
+
1550
+ iit ( 'should pass the transcluded content through to ng-transclude, ' +
1551
+ 'when not the highest directive' +
1552
+ 'and with external template' , function ( ) {
1553
+
1501
1554
module ( function ( $compileProvider ) {
1502
1555
// This directive transcludes its contents and hopes to use the
1503
1556
// transcluded content in its template
@@ -1520,7 +1573,6 @@ describe('$compile', function() {
1520
1573
'<div noop>' +
1521
1574
' <div ng-if="true">' +
1522
1575
' <div ng-transclude></div>' +
1523
- ' _this should be removed_' +
1524
1576
' </div>' +
1525
1577
'</div>' ) ;
1526
1578
@@ -1534,6 +1586,44 @@ describe('$compile', function() {
1534
1586
} ) ;
1535
1587
} ) ;
1536
1588
1589
+ iit ( 'should pass the transcluded content through to ng-transclude, ' +
1590
+ 'when not the highest directive' +
1591
+ 'and with inline template' , function ( ) {
1592
+
1593
+ module ( function ( $compileProvider ) {
1594
+ // This directive transcludes its contents and hopes to use the
1595
+ // transcluded content in its template
1596
+ $compileProvider . directive ( 'transTest' , valueFn ( {
1597
+ template :
1598
+ // This is the template for the trans-test directive, it contains an
1599
+ // ng-if, which also uses transclusion, which basically blocks the inner
1600
+ // trans-test directive from receiving any transcluded content
1601
+ '<div noop>' +
1602
+ ' <div ng-if="true">' +
1603
+ ' <div ng-transclude></div>' +
1604
+ ' </div>' +
1605
+ '</div>' ,
1606
+ transclude : true
1607
+ } ) ) ;
1608
+
1609
+ // This directive does nothing except to put a directive in the compile
1610
+ // element ancestors list between the root $compile node and the trans-test
1611
+ // directives' element
1612
+ $compileProvider . directive ( 'noop' , valueFn ( { } ) ) ;
1613
+ } ) ;
1614
+
1615
+ inject ( function ( $compile , $rootScope , $templateCache ) {
1616
+
1617
+ element = $compile ( '<div trans-test>transcluded content</div>' ) ( $rootScope ) ;
1618
+
1619
+ // The ngTransclude:orphan error gets thrown when the digest occurs since this
1620
+ // is when the ngTransclude directive tries to use the transcluded function.
1621
+ $rootScope . $digest ( ) ;
1622
+
1623
+ expect ( element . text ( ) . trim ( ) ) . toEqual ( 'transcluded content' ) ;
1624
+ } ) ;
1625
+ } ) ;
1626
+
1537
1627
1538
1628
it ( "should fail if replacing and template doesn't have a single root element" , function ( ) {
1539
1629
module ( function ( $exceptionHandlerProvider ) {
0 commit comments