@@ -1443,125 +1443,159 @@ describe('$compile', function() {
1443
1443
}
1444
1444
) ) ;
1445
1445
1446
- iit ( 'should pass the transcluded content through to ng-transclude' , function ( ) {
1446
+ // it('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
+
1457
+ // inject(function($compile, $rootScope, $templateCache) {
1458
+ // // This is the template for the trans-test directive, it contains an
1459
+ // // ng-if, which also uses transclusion, which basically blocks the inner
1460
+ // // trans-test directive from receiving any transcluded content
1461
+ // $templateCache.put('transTestTemplate',
1462
+ // ' <div ng-if="true">'+
1463
+ // ' <div ng-transclude></div>'+
1464
+ // '</div>');
1465
+
1466
+ // element = $compile('<div trans-test>transcluded content</div>')($rootScope);
1467
+
1468
+ // // The ngTransclude:orphan error gets thrown when the digest occurs since this
1469
+ // // is when the ngTransclude directive tries to use the transcluded function.
1470
+ // $rootScope.$digest();
1471
+
1472
+ // expect(element.text().trim()).toEqual('transcluded content');
1473
+ // });
1474
+ // });
1475
+
1476
+
1477
+ // it('nested ngIfs should transclude correctly', function() {
1478
+
1479
+ // module(function($compileProvider) {
1480
+ // // This directive does nothing except to put a directive in the compile
1481
+ // // element ancestors list between the root $compile node and the trans-test
1482
+ // // directives' element
1483
+ // $compileProvider.directive('noop', valueFn({}));
1484
+ // });
1485
+
1486
+ // inject(function($compile, $rootScope) {
1487
+ // element = $compile('<div noop><div ng-if="true">outer<div ng-if="true">inner</div></div></div>')($rootScope);
1488
+
1489
+ // // The ngTransclude:orphan error gets thrown when the digest occurs since this
1490
+ // // is when the ngTransclude directive tries to use the transcluded function.
1491
+ // $rootScope.$digest();
1492
+
1493
+ // expect(element.text().trim()).toEqual('outerinner');
1494
+ // });
1495
+ // });
1496
+
1497
+
1498
+ // it('should pass the transcluded content through to ng-transclude, ' +
1499
+ // 'when not the highest directive' +
1500
+ // 'and with external template', function() {
1501
+
1502
+ // module(function($compileProvider) {
1503
+ // // This directive transcludes its contents and hopes to use the
1504
+ // // transcluded content in its template
1505
+ // $compileProvider.directive('transTest', valueFn({
1506
+ // templateUrl: 'transTestTemplate',
1507
+ // transclude: true
1508
+ // }));
1509
+
1510
+ // // This directive does nothing except to put a directive in the compile
1511
+ // // element ancestors list between the root $compile node and the trans-test
1512
+ // // directives' element
1513
+ // $compileProvider.directive('noop', valueFn({}));
1514
+ // });
1515
+
1516
+ // inject(function($compile, $rootScope, $templateCache) {
1517
+ // // This is the template for the trans-test directive, it contains an
1518
+ // // ng-if, which also uses transclusion, which basically blocks the inner
1519
+ // // trans-test directive from receiving any transcluded content
1520
+ // $templateCache.put('transTestTemplate',
1521
+ // '<div noop>'+
1522
+ // ' <div ng-if="true">'+
1523
+ // ' <div ng-transclude></div>'+
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
+
1537
+ // it('should pass the transcluded content through to ng-transclude, ' +
1538
+ // 'when not the highest directive' +
1539
+ // 'and with inline template', function() {
1540
+
1541
+ // module(function($compileProvider) {
1542
+ // // This directive transcludes its contents and hopes to use the
1543
+ // // transcluded content in its template
1544
+ // $compileProvider.directive('transTest', valueFn({
1545
+ // template:
1546
+ // // This is the template for the trans-test directive, it contains an
1547
+ // // ng-if, which also uses transclusion, which basically blocks the inner
1548
+ // // trans-test directive from receiving any transcluded content
1549
+ // '<div noop>'+
1550
+ // ' <div ng-if="true">'+
1551
+ // ' <div ng-transclude></div>'+
1552
+ // ' </div>'+
1553
+ // '</div>',
1554
+ // transclude: true
1555
+ // }));
1556
+
1557
+ // // This directive does nothing except to put a directive in the compile
1558
+ // // element ancestors list between the root $compile node and the trans-test
1559
+ // // directives' element
1560
+ // $compileProvider.directive('noop', valueFn({}));
1561
+ // });
1447
1562
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
- } ) ;
1563
+ // inject(function($compile, $rootScope, $templateCache) {
1456
1564
1457
- inject ( function ( $compile , $rootScope , $templateCache ) {
1458
- // This is the template for the trans-test directive, it contains an
1459
- // ng-if, which also uses transclusion, which basically blocks the inner
1460
- // trans-test directive from receiving any transcluded content
1461
- $templateCache . put ( 'transTestTemplate' ,
1462
- ' <div ng-if="true">' +
1463
- ' <div ng-transclude></div>' +
1464
- '</div>' ) ;
1565
+ // element = $compile('<div trans-test>transcluded content</div>')($rootScope);
1465
1566
1466
- element = $compile ( '<div trans-test>transcluded content</div>' ) ( $rootScope ) ;
1567
+ // // The ngTransclude:orphan error gets thrown when the digest occurs since this
1568
+ // // is when the ngTransclude directive tries to use the transcluded function.
1569
+ // $rootScope.$digest();
1467
1570
1468
- // The ngTransclude:orphan error gets thrown when the digest occurs since this
1469
- // is when the ngTransclude directive tries to use the transcluded function.
1470
- $rootScope . $digest ( ) ;
1571
+ // expect(element.text().trim()).toEqual('transcluded content');
1572
+ // });
1573
+ // } );
1471
1574
1472
- expect ( element . text ( ) . trim ( ) ) . toEqual ( 'transcluded content' ) ;
1473
- } ) ;
1474
- } ) ;
1475
1575
1476
-
1477
- iit ( 'nested ngIfs should transclude correctly' , function ( ) {
1576
+
1577
+
1578
+ iit ( 'should allow nested transclude directives' , function ( ) {
1478
1579
1479
1580
module ( function ( $compileProvider ) {
1480
- // This directive does nothing except to put a directive in the compile
1481
- // element ancestors list between the root $compile node and the trans-test
1482
- // directives' element
1483
- $compileProvider . directive ( 'noop' , valueFn ( { } ) ) ;
1484
- } ) ;
1485
-
1486
- inject ( function ( $compile , $rootScope ) {
1487
- element = $compile ( '<div noop><div ng-if="true">outer<div ng-if="true">inner</div></div></div>' ) ( $rootScope ) ;
1488
-
1489
- // The ngTransclude:orphan error gets thrown when the digest occurs since this
1490
- // is when the ngTransclude directive tries to use the transcluded function.
1491
- $rootScope . $digest ( ) ;
1492
-
1493
- expect ( element . text ( ) . trim ( ) ) . toEqual ( 'outerinner' ) ;
1494
- } ) ;
1495
- } ) ;
1496
1581
1497
- iit ( 'should pass the transcluded content through to ng-transclude, ' +
1498
- 'when not the highest directive' +
1499
- 'and with external template' , function ( ) {
1582
+ $compileProvider . directive ( 'noop' , valueFn ( { } ) ) ;
1500
1583
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' ,
1584
+ $compileProvider . directive ( 'transclude1' , valueFn ( {
1585
+ template : '<div noop><div transclude2><div ng-transclude></div></div></div>' ,
1506
1586
transclude : true
1507
1587
} ) ) ;
1508
1588
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
- ' </div>' +
1524
- '</div>' ) ;
1525
-
1526
- element = $compile ( '<div trans-test>transcluded content</div>' ) ( $rootScope ) ;
1527
-
1528
- // The ngTransclude:orphan error gets thrown when the digest occurs since this
1529
- // is when the ngTransclude directive tries to use the transcluded function.
1530
- $rootScope . $digest ( ) ;
1531
-
1532
- expect ( element . text ( ) . trim ( ) ) . toEqual ( 'transcluded content' ) ;
1533
- } ) ;
1534
- } ) ;
1535
-
1536
- iit ( 'should pass the transcluded content through to ng-transclude, ' +
1537
- 'when not the highest directive' +
1538
- 'and with inline template' , function ( ) {
1539
-
1540
- module ( function ( $compileProvider ) {
1541
- // This directive transcludes its contents and hopes to use the
1542
- // transcluded content in its template
1543
- $compileProvider . directive ( 'transTest' , valueFn ( {
1544
- template :
1545
- // This is the template for the trans-test directive, it contains an
1546
- // ng-if, which also uses transclusion, which basically blocks the inner
1547
- // trans-test directive from receiving any transcluded content
1548
- '<div noop>' +
1549
- ' <div ng-if="true">' +
1550
- ' <div ng-transclude></div>' +
1551
- ' </div>' +
1552
- '</div>' ,
1589
+ $compileProvider . directive ( 'transclude2' , valueFn ( {
1590
+ template : '<div ng-transclude></div>' ,
1553
1591
transclude : true
1554
1592
} ) ) ;
1555
1593
1556
- // This directive does nothing except to put a directive in the compile
1557
- // element ancestors list between the root $compile node and the trans-test
1558
- // directives' element
1559
- $compileProvider . directive ( 'noop' , valueFn ( { } ) ) ;
1560
1594
} ) ;
1561
1595
1562
1596
inject ( function ( $compile , $rootScope , $templateCache ) {
1563
1597
1564
- element = $compile ( '<div trans-test >transcluded content</div>' ) ( $rootScope ) ;
1598
+ element = $compile ( '<div transclude1 >transcluded content</div>' ) ( $rootScope ) ;
1565
1599
1566
1600
// The ngTransclude:orphan error gets thrown when the digest occurs since this
1567
1601
// is when the ngTransclude directive tries to use the transcluded function.
@@ -1572,6 +1606,7 @@ describe('$compile', function() {
1572
1606
} ) ;
1573
1607
1574
1608
1609
+
1575
1610
it ( "should fail if replacing and template doesn't have a single root element" , function ( ) {
1576
1611
module ( function ( $exceptionHandlerProvider ) {
1577
1612
$exceptionHandlerProvider . mode ( 'log' ) ;
0 commit comments